Question: 1. (1 point) (check all that apply) How can we name elements of list x= list(1,2,c(1,2))? A) names(x) = c(H, M, L) B) dimnames(x) =

1. (1 point) (check all that apply) How can we name elements of list x= list(1,2,c(1,2))?

A) names(x) = c("H", "M", "L")

B) dimnames(x) = list("H", "M", "L")

C) x = list(H=1, M = 2, L = c(1,2))

D) none of the above

2. (1 point) x is a data frame. Then x[,c(1,2)] is

A) a list

B) a data frame

C) a vector

D) a matrix

E) a cell value

3. (1 point) What is ifelse() function different from if-else statement?

A) it can generate a vector

B) It applies to each value of a vector without a loop

C) it is simper than if-else statement

D) it cannot test more than one set of conditions

4. (1 point) df = data.frame(x=as.numeric(), y = as.numeric()). Then how would you find the maximum of y for those rows which x vale is greater than 100?

A) max(df[which(df$x>100),]$y)

B) max(df[which(x>100),y)

C) max(subset(df, x>100))

D) max(y[x>100])

5. (1 point) df = data.frame(x=as.numeric(), y = as.character()). Then how would you find the mean value of x for each value of y?

A) mean(df$x) B) mean(df$x, df$y) C) tapply(df$x, df$y, mean) D) select mean(x) from df group by y

6. (1 point) df = data.frame(x=as.numeric(), y = as.character(), z = as.numeric()). Then how do you subset the data frame to columns x and y and rows which x is over 100?

A) subset(df, x> 100)[,c("x","y")]

B) df[which(x> 100),c("x","y")]

C) df[x>100]$c("x","y")

D) df$c(("x","y")[x>100]

E) data.frame(df[[x>100]]$x, df[[x>100]]$z)

7. (1 point) Map(f, list.A) is identical to which of the following

A) sapply(list.A, f)

B) apply(list.A, f)

C) lapply(list.A, f)

D) tapply(list.A, f)

8. (1 point) Suppose we want split data frame df to take Case 1, 4, 7, ... into one data table, Case 2, 5, 8, ... into the second data table, and Case 3, 6, 9, ... into the last data table. Which one of the following is correct?

A) subset(df, c(1,4,7) | c(2,5,8) | c(3,6,9))

B) subset(df, (1:nrow(df)) %% 3 ==1)

C) split(df, (1:nrow(df)) %% 3 ==1)

D) split(df, (1:nrow(df)) %% 3)

9. (1 point) (check all that apply) After splitting data frame df using split function, how could you combine the result of the split, l.df, into one data table? A) Reduce(rbind, l.df)

B) Reduce(function(x,y) merge(x,y,all.x=T, all.y=T), l.df)

C) merge(l.df[1],l.df[2])

D) merge(merge(l.df[1],l.df[2]), l.df[3])

10. (1 point) (check all that apply) To user merge(x,y,by,join) function to merge two data tables, the full outer join will be done using the option:

A) all = T

B) all.x = T, all.y = T

C) all.x = T, all.y = F

D) all.x=F, all.y = T

E) all = F

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!