-
Notifications
You must be signed in to change notification settings - Fork 7
/
CastleOfR_Doors.txt
24 lines (24 loc) · 8.18 KB
/
CastleOfR_Doors.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
name direction_1to2 room1 room2 question1 solution1 val1 hint1 prepare1 cleanup1 question2 solution2 val2 hint2 prepare2 cleanup2
d_lounge_intro north lounge intro "What is [2 to the power of 3], times [10 minus 2]? (Use R!)" (2 ^ 3) * (10 - 2) 64 2 ^ 3 = 8 NA NA Ask for help on the solution() function using help() function. help(solution) NA ?help NA NA
d_intro_simple east intro simple A variable named x has been defined in your workspace. Please remove it. rm(x) NA rm "x <<- ""a""" "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})" "Create the sequence [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] without typing all elements." "seq(2, 20, 2)" NA ?seq NA NA
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. 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()})" The variable height holds the height of 10 men. The variable countries holds a factor representing in which country each man resides. Split height into separate lists of heights according to which country a man resides in. "split(height, countries)" NA The answer is in the question. "height <<- sample(160:200, 10); countries <<- gl(2, 5, labels = c(""Albania"", ""Turkey""))" "tryCatch(rm(height, countries, envir = globalenv()), warning = function(w) {invisible()})"
d_grouping_functions south grouping functions "sumSquared equals zero. Write a for loop which calculates the sum of the numbers 1 to 10 squared, and put the result in sumSquared." for (i in 1:10) sumSquared <- sumSquared + i ^ 2 NA ?for sumSquared <<- 0 "tryCatch(rm(sumSquared, envir = globalenv()), warning = function(w) {invisible()})" mystery <- function(x) {y <- x^2; return(x)} What does mystery(2) return? 2 2 Return to the basics. NA "tryCatch(rm(mystery, envir = globalenv()), warning = function(w) {invisible()})"
d_grouping_darkRoom3 east grouping darkRoom3 "Calculate the sum of the numbers 1 to 10 squared, without using any loop, and with the "":"" operator." sum((1:10)^2) NA Its that easy. NA NA NA NA NA NA NA NA
d_functions_models east functions models "A function f has been defined in your workspace. x is a variable which equals 2. What would be the value of x after calling ""f(3)""?" x 2 Scope. x <<- 2; f <<- function(y) x <- y "tryCatch(rm(x, f, envir = globalenv()), warning = function(w) {invisible()})" "Fit a linear regression model of y over x1 and x2 including an interaction term. Do not use the ""+"" sign." lm(y ~ x1 * x2) NA * "x1 <<- rnorm(20, 3, 4); x2 <<- runif(20, 3, 4); y <<- 2 * x1 * x2 -5 + rnorm(20); " "tryCatch(rm(x1, x2, y, envir = globalenv()), warning = function(w) {invisible()})"
d_models_darkRoom3 north models darkRoom3 lm1 is a linear model object with an intercept. Get its intercept. coef(lm1)[1] NA ?coef "x <<- rnorm(20, 3, 4); y <<- 2 * x + 1 + rnorm(20); lm1 <- lm(y ~ x)" "tryCatch(rm(x, y, lm1, envir = globalenv()), warning = function(w) {invisible()})" NA NA NA NA NA NA
d_models_plots east models plots Produce a Normal QQ plot of the vnumeric vector v. qqnorm(v) NA ?qqnorm "v <<- rexp(100, 1)" "tryCatch(rm(v, envir = globalenv()), warning = function(w) {invisible()})" "This is the cos(x) plot of x defined in your workspace. Add the sin(x) line, in red. Use the word ""red""." "lines(x, sin(x), col = ""red"")" NA ?lines "x <<- seq(-10, 10, 0.1); plot(x, cos(x), col = ""green"", type = ""l"", ylim = c(-5, 5))" "tryCatch(rm(x, envir = globalenv()), warning = function(w) {invisible()})"
d_plots_timeRoom3 north plots timeRoom3 The ChickenWeight dataset : Plot a boxplot of the chickens weight after 20 days. boxplot(ChickWeight$weight[ChickWeight$Time == 20]) NA The answer is in the question. NA NA NA NA NA NA NA NA
d_functions_osTower up functions osTower Get the dimensions of the attitude dataset. dim(attitude) NA The answer is in the question. NA NA what is 1 + 1? 1+1 2 two… NA NA
d_plots_packagesTower up plots packagesTower "What to add before ""plot(x, y); plot(x, z)"" in order to make the two plots appear side by side?" "par(mfrow = c(1, 2)" NA ?par NA "par(mfrow = c(1,1))" what is 1 + 1? 1+1 2 two… NA NA