R Basic-Dumps - Classicoder.com - CLASSIC CODER #header (Ativar o PHP)

R Basic-Dumps - Classicoder.com

 


Assume that you have a vector x <-c(3,5,1,10,12,6) and you wish to set all elements of this

vector that are smaller than 6 to be equal to 0, what R code accomplishes this?

Answer:  X[X<6]<-0


What would be the result of following code?

x<-c("x", "y", "z") as.logical(x)

Answer:  NA NA NA


If I have two vectors, x<-c(1,3,5) and y<-c(3,2,10), what does rbind(x,y) give?

Answer:  A 2 x 3 matrix


Which command allows you to get the median tree Height of the R sample dataset "trees"?

Answer:  median(trees$Height)


Which function is used to generate Sequences in R?

Answer:  seq()


Which of the following statements is correct?

Answer:  NaN can also be thought of as a missing value.


What is the output of the R code?

m<-c(1, 2, 3) n<-c(6, 5, 4) (m<2) & (n> 5)

Answer:  TRUE FALSE FALSE


Which function can be used to create collection of vectors objects?

Answer:  c()


An important property of vectors in R is that

Answer:  All elements must be of the same class


What command will you enter in the R console to get help on how to quit R?

Answer:  help(q)


Which R command creates a 2 by 2 matrix with the values 1, 2, 3, and 4?

Answer:  m <- matrix(1:4, 2, 2)


Which of the following statements is correct?

Answer:  All the options


What would be the result of following code?

x <- 0:4 as.logical(x)

Answer:  FALSE TRUE TRUE TRUE TRUE


Which of the following while loops will print numbers from 1 to 4?

Answer: x<-1 while(x < 5) { print(x); x <-x+1;}


What is the class of the object defined by the expression x<-c(4,"a",TRUE) in R?

Answer:  Character


Which of the following statements is correct?

Answer:  All the options


What is the function in R to get the # of observations in a data frame?

Answer:  nobs() and n() [***Both WRONG]