Skip to content

Commit

Permalink
Add riddles to 2nd floor rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
Giora Simchoni committed Sep 6, 2017
1 parent a372835 commit f8fb0fe
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 26 deletions.
20 changes: 10 additions & 10 deletions inst/extdata/CastleOfR_Doors.txt
Expand Up @@ -4,16 +4,16 @@ d_intro_simple east intro simple A variable named x has been defined in your wor
d_simple_objectsRoom east simple objectsRoom A vector named x has been defined in your workspace. Put a missing value in the 2nd element of x. x[2] <- NA NA ?`NA` x <<- 1:5 "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})" What is the class of variable DF? class(DF) NA The answer is in the question. "DF <<- data.frame(x = 1:3, y = 4:6)" "tryCatch(rm(DF, envir = globalenv()), warning = function(w) {invisible()})"
d_simple_darkRoom1 south simple darkRoom1 "Concatenate the strings ""tea"" and ""cup"" using the paste0 function" "paste0(""tea"", ""cup"")" NA ?paste0 NA NA NA NA NA NA NA NA
d_objectsRoom_factors south objectsRoom factors How do you get the value of pi in R? pi NA You just did. NA NA Get the min and max of vector n with a single function. range(n) NA ?range "n <<- sample(1:10, 5)" "tryCatch(rm(n, envir = globalenv()), warning = function(w) {invisible()})"
d_factors_darkRoom1 west factors darkRoom1 "Turn the character vector a into a factor. Assign it to variable b. Don't use ""as""." b <- factor(a) NA The answer is in the question. "a <<- c(rep(""a"", 3), rep(""b"", 4), rep(""c"", 5))" "tryCatch(rm(a, b, envir = globalenv()), warning = function(w) {invisible()})" NA NA NA NA NA NA
d_factors_arrays up factors arrays The variable height holds the height of 10 men. The variable countries holds a factor representing in which country each man resides. Find the minimum height for each country. "tapply(height, countries, min)" NA ?tapply "height <<- sample(160:200, 10); countries <<- gl(2, 5, labels = c(""Albania"", ""Turkey""))" "tryCatch(rm(height, countries, envir = globalenv()), warning = function(w) {invisible()})" what is 1 + 1? 1+1 2 two� NA NA
d_arrays_lists west arrays lists what is 0 + 0? 0+0 0 zero� NA NA what is 1 + 1? 1+1 2 two� NA NA
d_arrays_darkRoom2 north arrays darkRoom2 what is 0 + 0? 0+0 0 zero� NA NA NA NA NA NA NA NA
d_lists_timeRoom2 west lists timeRoom2 what is 0 + 0? 0+0 0 zero� NA NA NA NA NA NA NA NA
d_lists_reading north lists reading what is 0 + 0? 0+0 0 zero� NA NA what is 1 + 1? 1+1 2 two� NA NA
d_reading_darkRoom2 east reading darkRoom2 what is 0 + 0? 0+0 0 zero� NA NA NA NA NA NA NA NA
d_reading_probability west reading probability what is 0 + 0? 0+0 0 zero� NA NA what is 1 + 1? 1+1 2 two� NA NA
d_probability_timeRoom2 south probability timeRoom2 what is 0 + 0? 0+0 0 zero� NA NA NA NA NA NA NA NA
d_probability_grouping up probability grouping what is 0 + 0? 0+0 0 zero� NA NA what is 1 + 1? 1+1 2 two� NA NA
d_factors_darkRoom1 west factors darkRoom1 "Turn the character vector a into a factor. Assign it to variable b. Do not use ""as""." b <- factor(a) NA The answer is in the question. "a <<- c(rep(""a"", 3), rep(""b"", 4), rep(""c"", 5))" "tryCatch(rm(a, b, envir = globalenv()), warning = function(w) {invisible()})" NA NA NA NA NA NA
d_factors_arrays up factors arrays The variable height holds the height of 10 men. The variable countries holds a factor representing in which country each man resides. Find the minimum height for each country. "tapply(height, countries, min)" NA ?tapply "height <<- sample(160:200, 10); countries <<- gl(2, 5, labels = c(""Albania"", ""Turkey""))" "tryCatch(rm(height, countries, envir = globalenv()), warning = function(w) {invisible()})" "The expression matrix(1:3, ncol = 3, nrow = 4) results in an error. TRUE or FALSE?" FALSE NA Try it and see.. NA NA
d_arrays_lists west arrays lists Get a frequency table of the vector x. table(x) NA "Not ""frequency""." "x <<- c(rep(""escape"", 5), rep(""from"", 4), rep(""OS"", 6), rep(""Tower"", 2))" "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})" Get the second element of list l. l[[2]] NA ?Extract "l <<- list(a = ""do not go west"", b = ""lounge has objects"", c = ""Lady R is coming"")" "tryCatch(rm(l, envir = globalenv()), warning = function(w) {invisible()})"
d_arrays_darkRoom2 north arrays darkRoom2 Multiply all elements in array z by 3. z * 3 NA That easy. "z <<- array(1:12, c(3, 4))" "tryCatch(rm(z, envir = globalenv()), warning = function(w) {invisible()})" NA NA NA NA NA NA
d_lists_timeRoom2 west lists timeRoom2 Sort the area column of the rock dataset in decreasing order. "sort(rock$area, decreasing = TRUE)" NA decreasing = TRUE NA NA NA NA NA NA NA NA
d_lists_reading north lists reading "Set the name of the fourth element in list y, to ""dragon""" "names(y)[4] <- ""dragon""" NA names(y) "y <<- list(""one"" = 1, ""two"" = 2, ""three"" = 3, ""four"" = 4)" "tryCatch(rm(y, envir = globalenv()), warning = function(w) {invisible()})" What is the parameter in read.table to use if you want to skip 10 rows? skip NA ?read.table NA NA
d_reading_darkRoom2 east reading darkRoom2 "path_to_example2_file contains the path to the example2 csv file in your system. Read it as a data frame, name it example2.df. It does not have a header, name its columns c(""A"", ""B"", ""C"", ""D"")." "example2.df <- read.csv(path_to_example2_file, header = FALSE, col.names = c(""A"", ""B"", ""C"", ""D""))" 0 ?read.csv "path_to_example2_file <<- system.file(""extdata"", ""example2.csv"", package = ""CastleOfR"")" "tryCatch(rm(path_to_example2_file, example2.df, envir = globalenv()), warning = function(w) {invisible()})" NA NA NA NA NA NA
d_reading_probability west reading probability Get the first 10 rows of the airquality dataset without using square brackets. "head(airquality, 10)" NA Head towards the 4th floor. NA NA What is the quickest way of getting a vector of the letters a to z? letters NA The answer is in the question. NA NA
d_probability_timeRoom2 south probability timeRoom2 Plot a histogram of a random sample of size 1000 of an Exponential distribution with rate = 3. "hist(rexp(1000, 3))" NA ?hist NA NA NA NA NA NA NA NA
d_probability_grouping up probability grouping "How do you get the min, the max, the mean and median of the vector x in a single function?" summary(x) NA ?summary "x <<- runif(20, -10, 10)" "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})" what is 1 + 1? 1+1 2 two� NA NA
d_grouping_functions south grouping functions what is 0 + 0? 0+0 0 zero� NA NA what is 1 + 1? 1+1 2 two� NA NA
d_grouping_darkRoom3 east grouping darkRoom3 what is 0 + 0? 0+0 0 zero� NA NA NA NA NA NA NA NA
d_functions_models east functions models what is 0 + 0? 0+0 0 zero� NA NA what is 1 + 1? 1+1 2 two� NA NA
Expand Down
18 changes: 9 additions & 9 deletions inst/extdata/CastleOfR_Objects.txt
Expand Up @@ -5,17 +5,17 @@ o_simple_3 simple bottle on a bed tip 0 Assign 7 to the a variable named x. x <-
o_simple_4 simple book on a stand power 3 A vector named x has been defined in your workspace. How do you get the square root of all elements in x? sqrt(x) NA 7 chars answer NA 0 "x <<- c(4, 9, 16)" "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})"
o_objectsRoom_5 objectsRoom tissue on the floor power 3 Find out the length of a variable named z. length(z) NA The answer is in the question. NA 0 z <<- 1:999 "tryCatch(rm(z, envir = globalenv()), warning = function(w) {invisible()})"
o_objectsRoom_6 objectsRoom picture on the wall map 0 The vector digits contains the digits 1 to 9 as characters. Convert them to numeric. as.numeric(digits) NA ?as.numeric NA 1 digits <<- as.character(1:9) "tryCatch(rm(digits, envir = globalenv()), warning = function(w) {invisible()})"
o_objectsRoom_7 objectsRoom can in an open box tip 0 Find out if the variable p contains a string is.character(p) NA p "If you lock a door after you've opened it, it will take Lady R longer to get you. Try ?lockDoor." 0 "p <<- ""is.character(p)""" "tryCatch(rm(p, envir = globalenv()), warning = function(w) {invisible()})"
o_objectsRoom_7 objectsRoom can in an open box tip 0 Find out if the variable p contains a string is.character(p) NA p "If you lock a door after you have opened it, it will take Lady R longer to get you. Try ?lockDoor." 0 "p <<- ""is.character(p)""" "tryCatch(rm(p, envir = globalenv()), warning = function(w) {invisible()})"
o_factors_8 factors coin in a dustbin pwd 0 What is the mean of vector v? mean(v) NA The answer is in the question. NA 0 v <<- runif(10) "tryCatch(rm(v, envir = globalenv()), warning = function(w) {invisible()})"
o_factors_9 factors brush on a shelf power 3 fac is a factor vector. What are its levels? levels(fac) NA The answer is in the question. NA 0 "fac <<- gl(3, 4, labels = c(""dont"", ""go"", ""west""))" "tryCatch(rm(fac, envir = globalenv()), warning = function(w) {invisible()})"
o_arrays_10 arrays credit card attached to one of the doors power 3 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_arrays_11 arrays umbrella hung on the wall tip 0 what is 0 + 0? 0 + 0 0 zero� If you forgot the question try ?whatWasTheQuestion. 0 NA NA
o_lists_12 lists button on the floor pwd 0 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_lists_13 lists lighter on a chair power 3 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_reading_14 reading lipstick in a dustbin tip 0 what is 0 + 0? 0 + 0 0 zero� Know your resources. Try ?whatDoIHave. 0 NA NA
o_reading_15 reading jar on a shelf power 3 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_probability_16 probability banknote attached to one of the doors power 3 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_probability_17 probability comb on a stand pwd 0 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_arrays_10 arrays credit card attached to one of the doors power 3 How would you bind the 3D vectors x and y into a matrix of dimensions 3 x 2? "cbind(x, y)" NA ?cbind NA 0 "x <<- c(4, 9, 16); y <<- c(3, -1, 8)" "tryCatch(rm(x, y, envir = globalenv()), warning = function(w) {invisible()})"
o_arrays_11 arrays umbrella hung on the wall tip 0 Define an array of size 3 x 5 containing all zeros. Assign it to variable a. "a <- array(0, c(3, 5))" NA ?array If you forgot the question try ?whatWasTheQuestion. 0 NA "tryCatch(rm(fac, envir = globalenv()), warning = function(w) {invisible()})"
o_lists_12 lists lighter on the floor power 0 Append the value 3 to the beginning of list w. "w <- c(3, w)" NA c NA 0 "w <<- list(4, ""get the button"", 6)" "tryCatch(rm(w, envir = globalenv()), warning = function(w) {invisible()})"
o_lists_13 lists button on a chair pwd 3 Get all rows of the faithful dataset in which the eruptions time was over 5 minutes. Do not use the subset function. "faithful[faithful$eruptions > 5, ]" NA ?faithful NA 0 NA NA
o_reading_14 reading lipstick in a dustbin tip 0 "path_to_example1_file contains the path to the example1 text file in your system. Read it as a data frame, name it example1.df. It has a header." "example1.df <- read.table(path_to_example1_file, header = TRUE)" NA ?read.table Know your resources. Try ?whatDoIHave. 0 "path_to_example1_file <<- system.file(""extdata"", ""example1.txt"", package = ""CastleOfR"")" "tryCatch(rm(path_to_example1_file, example1.df, envir = globalenv()), warning = function(w) {invisible()})"
o_reading_15 reading jar on a shelf power 3 path_to_example3_file contains the path to the example3 RData file in your system. Load it. load(path_to_example3_file) NA The answer is in the question. NA 0 "path_to_example3_file <<- system.file(""extdata"", ""example3.RData"", package = ""CastleOfR"")" "tryCatch(rm(path_to_example3_file, example1.df, envir = globalenv()), warning = function(w) {invisible()})"
o_probability_16 probability banknote attached to one of the doors power 3 "Get the 0.95 percentile of the standard normal distribution (mean = 0, sd = 1)" qnorm(0.95) 0 ?qnorm NA 0 NA NA
o_probability_17 probability comb on a stand pwd 0 "Get a random sample of size 10 from the U(0, 10) distribution." "runif(10, 0, 10)" 0 ?runif NA 0 NA NA
o_grouping_18 grouping hat on a chair pwd 0 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_grouping_19 grouping a hand mirror in the corner power 3 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
o_functions_20 functions toothbrush on a bed power 3 what is 0 + 0? 0 + 0 0 zero� NA 0 NA NA
Expand Down
14 changes: 7 additions & 7 deletions inst/extdata/CastleOfR_TimeRoomsRiddles.txt
@@ -1,13 +1,13 @@
name room question solution val hint prepare cleanup
r_timeRoom2_1 timeRoom2 "Create a vector of length 5 containing all twos, assign it to a variable named y" "y <- rep(2, 5)" NA Repeat two 5 times. NA "tryCatch(rm(y, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom2_2 timeRoom2 How do you list all current objects? ls() NA Unix "a <<- ""a""; b <<- ""b""; c <<- ""c""" "rm(list = ls(), envir = global.env())"
r_timeRoom2_2 timeRoom2 How do you list all current objects? ls() NA Unix "a1 <<- ""a""; b1 <<- ""b""; c1 <<- ""c""" "rm(list = ls(), envir = global.env())"
r_timeRoom2_3 timeRoom2 Check which elements of a vector named x are greater than -1. x > -1 NA Result should be a logical vector containing only TRUE/FALSE "x <<- c(34, -1, -10, 22, -5)" "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom2_4 timeRoom2 There are missing values in a vector named z. Put zeros in there. z[is.na(z)] <- 0 NA ?is.na "z <<- c(""a"", NA, 1, TRUE, NA)" "tryCatch(rm(z, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom2_5 timeRoom2 "What is the sum of vector v, omitting missing values?" "sum(v, na.rm = TRUE)" NA na.rm v <<- runif(5); v[6] <- NA "tryCatch(rm(v, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom3_6 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
r_timeRoom3_7 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
r_timeRoom3_8 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
r_timeRoom3_9 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
r_timeRoom3_10 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
r_timeRoom3_11 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
r_timeRoom3_6 timeRoom3 What is the inverse of matrix A? solve(A) NA Solve this problem quickly. "A <<- matrix(c(1:4, 9, 8, 5, 6, 7), c(3, 3))" "tryCatch(rm(A, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom3_7 timeRoom3 Get rows 21 to 40 of the airquality dataset using the head and tail functions. "tail(head(airquality, 40), 20)" NA "tail, head." NA NA
r_timeRoom3_8 timeRoom3 Get all rows of the faithful dataset in which the eruptions time was over 5 minutes. Use the subset function. "subset(faithful, eruptions > 5)" NA ?subset NA NA
r_timeRoom3_9 timeRoom3 Apply the mean function to each element of the list l. "lapply(l, mean)" NA ?lapply "l <<- list(1:3, 4:5, 10:14)" "tryCatch(rm(l, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom3_10 timeRoom3 Get the diagonal of matrix A diag(A) NA ??diagonal "A <<- matrix(c(1:4, 9, 8, 5, 6, 7), c(3, 3))" "tryCatch(rm(A, envir = globalenv()), warning = function(w) {invisible()})"
r_timeRoom3_11 timeRoom3 "Define a named list with two elements. The value of 1 named ""a"", the value of 2 named ""b""." "list(a = 1, b = 2)" NA Uhh.. ?list? NA NA
r_timeRoom3_12 timeRoom3 what is 0 + 0? 0+0 0 zero.. NA NA
11 changes: 11 additions & 0 deletions inst/extdata/example1.txt
@@ -0,0 +1,11 @@
a b c
0.301601015 0.182794153 0.996956735
0.699542192 0.308020014 0.207516645
0.105950656 0.888653211 0.024754042
0.427302209 0.732080114 0.469622006
0.280579872 0.734772668 0.808962717
0.114804784 0.469335069 0.996085419
0.095234452 0.838540969 0.1830606
0.652089278 0.340910176 0.099779189
0.970721244 0.650872355 0.436427513
0.361910183 0.700332518 0.007420289
7 changes: 7 additions & 0 deletions inst/extdata/example2.csv
@@ -0,0 +1,7 @@
a,1,2,3
b,2,3,4
c,3,4,5
d,4,5,6
e,5,6,7
f,6,7,8
g,7,8,9
Binary file added inst/extdata/example3.RData
Binary file not shown.

0 comments on commit f8fb0fe

Please sign in to comment.