R Programming Questions and Answers – Commands – 1

This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “Commands – 1”.

1. Which of the following code create n samples of size “size” with probability prob from the binomial?
a) z <- rinom(n,size,prob)
b) z <- rbinom(n,size,prob)
c) z <- binom(n,size,prob)
d) z >- nom(n,size,prob)
View Answer

Answer: b
Explanation: To use the rbinom() function, you need to define three parameters.

2. Which of the following code create a n item vector of random normal deviates?
a) x1 <- c(snorm(n))
b) x1 <- c(pnorm(n))
c) x1 <- c(rnorm(n))
d) x1 >- c(norm(n))
View Answer

Answer: c
Explanation: rnorm generates random deviates.

3. Which of the following statement can read csv files?
a) read.table(filename,header=TRUE,sep=’,’)
b) read.csv(filename,header=TRUE,sep=’,’)
c) read.tab(filename,header=TRUE,sep=’,’)
d) read.tab(filename,header=False,sep=’,’)
View Answer

Answer: a
Explanation: Each row of the table appears as one line of the file.

advertisement
advertisement

4. Which of the following statement read a tab or space delimited file?
a) read.table(filename,header=TRUE)
b) read.CSV(filename,header=TRUE)
c) read.table(filename,header=FALSE)
d) read.tableall(filename,header=TRUE)
View Answer

Answer: a
Explanation: read.csv and read.csv2 are identical to read.table except for the defaults.

5. which of the following statement chose those objects meeting a logical criterion?
a) sub(dataset,logical)
b) subset(dataset,logical)
c) subsetcon(dataset,logical)
d) subcon(dataset,logical)
View Answer

Answer: b
Explanation: R subsetting operators are powerful and fast.

Note: Join free Sanfoundry classes at Telegram or Youtube

6. Which of the following statement is another way to get a subset?
a) subsetcon(dataset,logical)
b) data.df[data.df=logical]
c) sub(dataset,logical)
d) subcon(dataset,logical)
View Answer

Answer: b
Explanation: subset(data.df,select=variables,logical) get those objects from a data frame that meet a criterion.

7. Which of the following sort a dataframe by the order of the elements in B?
a) x[rev(order(x$B)),]
b) x[ordersort(x$B),]
c) x[order(x$B),]
d) x[rev(x$B),]
View Answer

Answer: a
Explanation: x[rev(order(x$B)),] sort the dataframe in reverse order.

advertisement

8. Which of the following is Mac menu command?
a) browse.workspace
b) browse.works
c) browser.workspace
d) a statistical transformation
View Answer

Answer: a
Explanation: It is a Mac menu command that creates a window with information about all variables in the workspace.

9. _____ list the variables in the workspace.
a) rm(x)
b) rm(list=ls())
c) ls()
d) attach(mat)
View Answer

Answer: c
Explanation: rm(x) removes x from the workspace.

advertisement

10. ___________ remove all the variables from the workspace.
a) rm(x)
b) rm(list=ls())
c) ls()
d) attach(mat)
View Answer

Answer: b
Explanation: attach(mat) make the names of the variables in the matrix or data frame available in the workspace.

Sanfoundry Global Education & Learning Series – R Programming Language.

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

To practice all areas of R Programming Language, Here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.