| 
					
				 | 
			
			
				@@ -56,6 +56,34 @@ head(lottery649, 3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 tail(lottery649, 3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ``` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# A New Data Structure 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+```{r} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data1 <- c(1, 3, 5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data2 <- c(2, 4, 6) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data3 <- c(8, 9, 7) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+## Answer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+unnamed_list <- list(data1, data2, data3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+first_vector <- unnamed_list[[1]] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+named_list <-list(first = data1, second = data2, third = data3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+first_item_sum <- named_list$data1[1] + named_list$data2[1] + named_list$data3[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+``` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# Using pmap 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+```{r} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data1 <- c(1, 3, 5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data2 <- c(2, 4, 6) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data3 <- c(8, 9, 7) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+data_list <- list(data1, data2, data3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+## Answer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+averages <- pmap(data_list, function(x, y, z) { (x + y + z) / 3 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+first_average <- unlist(averages)[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+``` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Function for Historical Data Check 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ```{r} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -74,8 +102,8 @@ historical_lots <- pmap( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ```{r} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 library(sets) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-check_historical_occurrences <- function(lot, historical_lots = historical_lots) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  historical_matches <- map(historical_lots, function(x) {setequal(x, lot)}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+check_historical_occurrences <- function(lot, hist_lots = historical_lots) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  historical_matches <- map(hist_lots, function(x) {setequal(x, lot)}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   num_past_matches <- sum(unlist(historical_matches)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   s <- paste("The combination you entered has appeared ",  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              num_past_matches,  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -84,8 +112,8 @@ check_historical_occurrences <- function(lot, historical_lots = historical_lots) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   return(s) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 check_historical_occurrences(c(3, 12, 11, 14, 41, 43)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+check_historical_occurrences(c(1, 2, 3, 4, 5, 6)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ``` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # Multi-ticket Probability 
			 |