This set of tricky R Programming questions and answers focuses on “Commands”.

1. Which of the following code will drop the nth column ?

a) new <- old[-n,]
b) new <- old[,-n]
c) new <- old[,-c(i,j)]
d) new <- subset(old,logical)
[expand title="View Answer"]Answer:a
Explanation:new <- old[-n,] drops the nth row.[/expand]
2. Which of the following code drop the ith and jth column ?
a) new <- old[-n,]
b) new <- old[,-n]
c) new <- old[,-c(i,j)]
d) new <- subset(old,logical)
[expand title="View Answer"]Answer:c
Explanation:new <- subset(old,logical) select those cases that meet the logical condition.[/expand]
3. Which of the following statement find cases with no missing values ?
a) complete <- subset(data.df,complete.cases(data.df)
b) complete <- sub(data.df,complete.cases(data.df)
c) complete <- subset(data.df,completeall.cases(data.df)
d) new <- old[n1:n2,n3:n4]
[expand title="View Answer"]Answer:a
Explanation:new <- old[n1:n2,n3:n4] select the n1 through n2 rows of variables n3 through n4.[/expand]
4. Which of the following statement is normal distribution ?
a) dnorm(x, mean=0, sd=1, log = FALSE)
b) pnorm(q, mean=0, sd=1, lower.tail = TRUE, log.p = FALSE)
c) qnorm(p, mean=0, sd=1, lower.tail = TRUE, log.p = FALSE)
d) rnorm(n, mean=0, sd=1)
[expand title="View Answer"]Answer:a
Explanation:d stands for density.[/expand]
5. which of the following statement gives cumulative sum ?
a) cumsum(x,na=rm=TRUE)
b) cumprod(x)
c) cummax(x)
d) cummin(x)
[expand title="View Answer"]Answer:a
Explanation:cummax() function returns the cumulative maxima.[/expand]
6. Which of the following is uniform distribution ?
a) dunif(x, min=0, max=1, log = FALSE)
b) punif(q, min=0, max=1, lower.tail = TRUE, log.p = FALSE)
c) qunif(p, min=0, max=1, lower.tail = TRUE, log.p = FALSE)
d) runif(n, min=0, max=1)
[expand title="View Answer"]Answer:a
Explanation:These functions provide information about the uniform distribution on the interval from min to max.[/expand]
7. Which of the following truncates real x to integers ?
a) as.numeric(x)
b) as.integer(x)
c) as.order(x)
d) All of the mentioned
[expand title="View Answer"]Answer:b
Explanation:Compare to round(x,0) in R.[/expand]
8. Which of the following tests each element of x for membership in y ?
a) y%in%x
b) all(x)
c) any(x)
d) x%in%y
[expand title="View Answer"]Answer:d
Explanation:y%in%x tests each element of y for membership in x.[/expand]
9. Which of the following finds the maximum value in the vector x, exclude missing values
a) rm(x)
b) max(x, na.rm=TRUE)
c) all(x)
d) x%in%y
[expand title="View Answer"]Answer:b
Explanation:all(x%in%y) returns true if x is a proper subset of y.[/expand]
10. Which of the following produces the variance covariance matrix ?
a) sd(x, na.rm=TRUE)
b) mad(x, na.rm=TRUE)
c) fivenum(x, na.rm=TRUE)
d) var(x, na.rm=TRUE)
[expand title="View Answer"]Answer:d
Explanation:mad(x, na.rm=TRUE) gives median absolute deviation.[/expand]
**Sanfoundry Global Education & Learning Series – R Programming Language.**

Here’s the list of Best Reference Books in R Programming Language.

__Here is complete set of 1000+ Multiple Choice Questions and Answers__.