R Basics Assessment
R Basics Assessment
What would be the result of following code? x <- c("x", "y", "z") as.logical(x) -
a)x y z b)NA NA NA c)"x" "y" "z" d)NaN NaN NaN
Ans: d)NaN NaN NaN --Correct
If I have two vectors, x<-c(1,3,5) and y<-c(3,2,10), what does rbind(x,y) give?
a)A 3 x 2 matrix
b)A vector length of 2
c)A 2 x 3 matrix -- Correct
d)A vector length of 3
A 3 x 3 matrix
Ans: c)A 2 x 3 matrix --Correct
m
er as
Ans - a) c() --Correct
co
In R, the subsequent data types are all atomic data types except _____________.
eH w
Ans : Data Frame --Correct
o.
Which of the following statements is correct?
rs e
a)Use explicit TRUE and FALSE values when indicating logical values.
ou urc
b)R operates on named data structures.
c)All the options
d)rm command is used to remove objects in R.
Ans: c)All the options -- Correct
o
aC s
What command will you enter in the R console to get help on how to quit R?
vi y re
Which command allows you to get the median tree Height of the R sample dataset
"trees"?
Ans: median(trees$Height)
sh
What is the output of the R code? m <- c(1, 2, 3) n <- c(6, 5, 4) (m < 2) & (n >
5)
Ans: An error is thrown because the wrong operator is used. --Correct
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 study source was downloaded by 100000790328255 from CourseHero.com on 06-27-2021 07:16:05 GMT -05:00
https://www.coursehero.com/file/59704189/R-Basics-Assessmenttxt/
this?
Ans: x[x<6]<-0--Correct
What would be the output of the subsequent code? x <- c("a", "b", "c", "c", "d",
"a") x[c(1, 3, 4)]
Ans: "a" "c" "c" --Correct
m
er as
program.
d)All the options
co
Ans: d)All the options -- Correct
eH w
What is the function in R to get the # of observations in a data frame?
o.
Ans: nrow() --Correct
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh
This study source was downloaded by 100000790328255 from CourseHero.com on 06-27-2021 07:16:05 GMT -05:00
https://www.coursehero.com/file/59704189/R-Basics-Assessmenttxt/
Powered by TCPDF (www.tcpdf.org)