**R(Basics) QUIZ**

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

- man q
- help q
- help(q)

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

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

Q.What would be the result of following code? x <- 4 class(x)

- numeric
- Integer
- None of these

Q.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?

- x[x==6]<-0
- x[x<6]<-0
- x[x<6]==0

Q.What would be the result of following code? x <- 0:4 as.logical(x)

- NA NA NA NA NA
- 0 1 2 3 4
- FALSE TRUE TRUE TRUE TRUE

Q.In R, the subsequent data types are all atomic data types except _____________.

- Data frame
- Float
- Integer

Q.What is the output of the R code? m <- c(1, 2, 3) n <- c(6, 5, 4) (m < 2) & (n > 5)

- An error is thrown because the wrong operator is used
- True
- False
- {1,4}

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

- A 3 x 2 matrix
- A 2 x 3 matrix

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

- nobj()
- nrow()
- ntotal()

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

- m <- [1,2,;3,4]
- m <- matrix ( 1 -> 4; 2, 2)
- m <- matrix(1:4, 2, 2)

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

- Numeric
- Character
- Float

Q.Which function is used to generate Sequences in R?

- seqn()
- sequence()
- seq()
- order()

Q.Which of the following statements is correct?

- Number Inf represents infinity in R.
- The value Nan represents undefined value.
- All of these

Q.What would be the output of the subsequent code? x <- c("a", "b", "c", "c", "d", "a") x[c(1, 3, 4)]

- acd
- bcd
- "a""c""d"