Some questions ask for all the correct answers.
- What is the output?
y <- 3
x <- 5
x -> y
print c(x, y, 7)
a. [1] 3 3 7 b. [1] 3 5 7 c. [1]
5 3 7 d. [1] 5 5 7
- What is the output?
n <- 4
n <- n[-1]
print(n)
a. [1] -1
b. [1] 4
c. NULL
d. numeric(0)
- What is the output?
a <- "Apple"
b <- "Microsoft"
c <- "Sun"
print paste(a, b, c)
a. [1] AppleMicrosoftSun b. [1]
"AppleMicrosoftSun"
c. [1] "Apple Microsoft Sun" d. [1]
"Apple" "Microsoft" "Sun"
- Which if statements are correct? There may be more than one correct
answer.
a. if (length(x) > 5) b. if length(x) > 5 {
print("Yes") print("Yes")
}
c. if (length(x) > 5) d. if length(x) > 5
print "Yes" print("Yes")
end
- What is the output?
n <- 15
square <- function(n) n^2
print(square)
a. Error: Missing { b. 0
c. 225
d. function(n) n^2
- What the output?
matrix(1:6, 2, 3)
a. [,1] [,2] [,3] b. [,1] [,2] [,3]
[1,] 1 3 5 [1,] 1 2 3
[2,] 2 4 6 [2,] 4 5 6
c. [,1] [,2] d. [,1] [,2]
[1,] 1 4 [1,] 1 2
[2,] 2 5 [2,] 3 4
[3,] 3 6 [3,] 5 6
- Which statement prints the second element of this list named autos.
There may be more than one correct answer.
$days
[1] Mon Tue Wed Thu Fri
Levels: Fri Mon Thu Tue Wed
$cars
[1] 1 3 6 4 9
$trucks
[1] 2 5 4 5 12
$suvs
[1] 4 4 6 6 16
a. autos[2]
b. autos$[[2]]
c. autos@cars
d. autos$cars
- Which of the following is correct for reading this file. There may be
more than one correct answer.
days,cars,trucks,suvs
Mon,1,2,4
Tue,3,5,4
Wed,6,4,6
Thu,4,5,6
Fri,9,12,16
a. auto >- read.csv("autosales2.txt")
b. auto >- read.table("autosales2.txt")
c. auto >- read.table("autosales2.txt", sep=",")
d. auto >- read.table("autosales2.txt", sep=",", header=T)
- How many different algorithms are there for computing a percentile in R?
a. 1
b. 3 c. 5 d. 8
- Which function returns the column names of a data frame?
a. cols
b. columns
c. col.names
d. names
- What is the output?
pnorm(1, mean=0, sd=1)
a. [1] 0.5000000 b. [1] 0.6826895
c. [1] 0.8413447 d. [1] 0.9772499
- What is default uniform random number generator for R?
a. Knuth
TAOCP b. Mersenne Twister c. Super Duper
d. Wichman Hill
- Which plot is produced by this statement:
plot(runif(200), runif(200))
- What is the theoretical covariance of x and y?
u <- rnorm(500)
v <- rnorm(500)
w <- 0.8 * u + 0.6 * v
x <- 4 * u + 20
y <- 5 * w + 30
a.
0 b. 9
c. 16 d. 25
- If x is a numeric vector, which of the following defines a QQ plot. There may be more than one right answer.
a. qqnorm(x) b. qqplot(x)
c. qqplot(1:length(x), x)
d. qqplot(rnorm(length(x)), x)