These R multiple-choice questions and their answers will help you strengthen your grip on the subject of R. You can prepare for an upcoming exam or job interview with these 100+ R MCQs.
So scroll down and start answering.
A. lm(x ~ y)
B. proc reg; model y=x; run;
C. lm(y ~ x)
D. regress y x
A. ytemp <- rnorm(100, 0, 1); Y <- cut(ytemp, breaks=c(-10, -2, -1, 1, 2, 10))
B. Y <- rbinom(100, 5, 0.5)
C. Y <- sample(rep(c(1:5), each=20), size=100)
D. Y <- sample(c(1, 2, 3, 4, 5), 100, replace = TRUE)
A. for(i in 1:nnn) { <simulation code> }
B. for i in 1:nnn: <simulation code>
C. for(i - nnn) { <simulation code> }
D. for(i=1, nnn, 1) { <simulation code> }
A. It means a range from x to y.
B. It means that x and y are correlated.
C. It means that y logically follows from x.
D. It means that x and y are real numbers.
E. It means odds of x to y apply to this operation.
A. 2 10
B. 1 3 5 7 9
C. 2 4 6 8 10
D. 2
A. the data vector as it was in h
B. the entire array as an array
C. the array of all zeros
D. the dimension vector c(3,4,2)
A. [1] 2
B. [1] "Hello World"
C. NULL
D. NA
E. [1] Hello World
A. a = 1
B. a == 1
C. a <<- 1
D. a <- 1
E. a -> 1
A. 4
B. 3
C. TRUE
D. FALSE
E. 1
A. import.csv("X.csv")
B. import("X.csv")
C. read.csv("X.csv")
D. read("X.csv")
A. sort(X, decreasing=T)
B. sort(X)
C. order(X)
D. X[sort(X)]
A. summarize x
B. summary(x)
C. proc contents x;
D. summarize(x)
A. plot(X)
B. hist(X)
C. plot X
D. plot.hist(X)
A. x$1
B. x[0]
C. x.1
D. x[1]
E. x$0
A. 0
B. -2
C. NA
D. 2
A. objects
B. mode
C. events
D. commands
A. readdata
B. scan
C. read.csv
D. read.table
A. as.ts
B. is.ts
C. ts
D. if.ts
A. convert the data into integer
B. convert the data into vector
C. convert the data into matrices
D. convert the data into the time-series object
A. NA
B. NaN
C. #VALUE!
D. [a blank cell]
E. NULL
A. Surpresses printing of the word "Hello"
B. Right justifies the word "Hello"
C. Prints the word "Hello" in bold font
D. Increases the size of the word "Hello" by a factor of 2
A. xlim=c(0, 1)
B. xlimit="0, 1"
C. xlim="0, 1"
D. xlab=c(0, 1)
A. "The value of x is 2 and the value of y[x] is c(1:3)[2]"
B. "The value of x is 2 and the value of y[x] is 4"
C. "The value of x is 2 and the value of y[x] is 2"
D. "The value of x is 2 and the value of y[x] is 6"
A. 1 4
B. 1 4 7
C. 1 3 5
D. 1 2 3 4 5
A. lines(0, 1)
B. lty=c(0, 1)
C. abline(0, 1)
D. smooth.spline(0, 1)
A. [1] FALSE FALSE FALSE TRUE
B. [1] FALSE
C. Throws an error.
D. [1] TRUE
E. [1] NA NA NA TRUE
A. [1] TRUE [1] FALSE
B. [1] TRUE [1] TRUE
C. [1] FALSE [1] TRUE
D. NULL
E. [1] NaN [1] NA
A. 3
B. 1 2 3 4
C. 1 2 2 2 3 3
D. 1 2 3
A. read.table()
B. load.table()
C. load()
D. read()
A. tabulate(X, Y)
B. table(Y ~ X)
C. table(X*Y)
D. table(X, Y)
A. NA
B. TRUE
C. FALSE
D. -Inf
A. 1 2 1 2
B. 1 1
C. 1 1 3 3
D. 1 3 1 3
A. NULL
B. 2
C. 1.5
D. NA
A. 5 2
B. 10
C. 2 5
D. 20
A. lm(y ~ x1:x3 + x1:x2)
B. lm(y ~ x1 + x2 + x3 + x1*x2)
C. lm(y ~ x1 + x2 + x3 + interaction(x1, x2))
D. lm(y ~ x1:x2 + x3)
A. Time Series Analysis
B. Generalized Linear Models
C. Linear Mixed Effects Models
D. Analysis of Variance Models
E. Clustering Tools
A. x == y
B. x != y
C. x =! y
D. x =~ y
E. x %% y
A. mean(X[1:length(X[,1]),], na.rm=T)
B. apply(X, 1, mean, na.rm=T)
C. by(X, 1, mean, na.rm=T)
D. apply(X, 1, mean)
A. matrix(X, Y, Z, nrow=3)
B. matrix(cbind(X, Y, Z), nrow=3)
C. matrix(rbind(X, Y, Z), nrow=3)
D. matrix(rbind(X, Y, Z), ncol=3)
A. merge( X, Y, by = "ID")
B. merge( X, Y, by = "ID", all = TRUE )
C. merge( X, Y, sort = "ID", all = TRUE)
D. combine( X, Y, by = "ID")
A. matrix
B. vector
C. data.frame
D. list
E. array
A. sort( data.frame( x = c(10, -3, 4) ) )
B. sort( list( 10, -3, 4) )
C. sort( c( 10, -3, 4) )
D. sort( 10, -3, 4 )
A. lm(Y ~ X)$residuals
B. lm(Y ~ X)$residuals - lm(Y ~ X)$fitted.values
C. residuals(lm(Y ~ X))
D. Y - lm(Y - X)$fitted.values
A. equal to the result of: >c(mean(X[,1]), mean(X[,2]), mean(X[,3]))
B. equal to the result of: >c(mean(X[1,]), mean(X[2,]), mean(X[3,]), mean(X[4,]))
C. equal to the result of: >c(mean(X[,1]), mean(X[,2]), mean(X[,3]), mean(X[,4]))
D. equal to the result of: >c(mean(X[1,]), mean(X[2,]), mean(X[3,]))
A. X[c(3,7)] <- X[c(7,3)]
B. replace(X, c(3, 7), c(7,3)
C. X[7] <- X[3]; X[3] <- X[7]
D. X[3] <- X[7]; X[7] <- X[3]
A. [1] NULL
B. [1] TRUE
C. [1] -Inf
D. [1] NaN
E. [1] FALSE
A. An error message
B. NA
C. A correlation coefficient
D. R squared
A. scatter( X ~ Y )
B. plot( data.frame( Y ~ X ) )
C. plot( X ~ Y )
D. xyplot( X, Y )
A. True
B. 0
C. False
D. 110
A. the dimension vector c(3,4,2)
B. the entire array as an array
C. the array of all zeros
D. the data vector as it was in h