This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “Console Input and Evaluation – 1”.
1. What will be the output of the following R code?
> x <- 1 > print(x)
a) 1
b) 2
c) 3
d) 5
View Answer
Explanation: When a complete expression is entered at the prompt, it is evaluated and the result of the evaluated expression is returned.
2. Point out the wrong statement?
a) The grammar of the language determines whether an expression is complete or not
b) The <- symbol is the assignment operator in R
c) The ## character indicates a comment
d) R does not support multi-line comments or comment blocks
View Answer
Explanation: Unlike some other languages, R does not support multi-line comments or comment blocks.
3. Which of the R following code is example of explicit printing?
a)
> x <- 5 > x
b)
> x <- 5 > print(x)
c)
> x <- "auto" > x
d)
> x <- "auto" > x <- "auto"
Explanation: Print command is used for outputting the value.
4. Files containing R scripts ends with extension ____________
a) .S
b) .R
c) .Rp
d) .SP
View Answer
Explanation: Under many versions of UNIX and on Windows, R provides a mechanism for recalling and re-executing previous commands.
5. Point out the wrong statement?
a) : operator is used to create integer sequences
b) The numbers in the square brackets are part of the vector itself
c) There is a difference between the actual R object and the manner in which that R object is printed to the console
d) Files containing R scripts ends with extension .R
View Answer
Explanation: They are merely part of the printed output.
6. If commands are stored in an external file, say commands.R in the working directory work, they may be executed at any time in an R session with the command ____________
a) source(“commands.R”)
b) exec(“commands.R”)
c) execute(“commands.R”)
d) exect(“command.R”)
View Answer
Explanation: For Windows, Source is also available on the File menu.
7. _______ will divert all subsequent output from the console to an external file.
a) sink
b) div
c) exp
d) exc
View Answer
Explanation: sink() restores it to the console once again.
8. The entities that R creates and manipulates are known as ________
a) objects
b) task
c) container
d) packages
View Answer
Explanation: These may be variables, arrays of numbers, character strings, functions, or more general structures built from such components.
9. Which of the following can be used to display the names of (most of) the objects which are currently stored within R?
a) object()
b) objects()
c) list()
d) class()
View Answer
Explanation: During an R session, objects are created and stored by name.
10. Collection of objects currently stored in R is called as ________________
a) package
b) workspace
c) list
d) task
View Answer
Explanation: All objects created during an R session can be stored permanently in a file for use in future R sessions.
Sanfoundry Global Education & Learning Series – R Programming Language.
Here’s the list of Best Books in R Programming Language.
- Check R Programming Books
- Check Information Technology Books
- Practice Programming MCQs
- Apply for Programming Internship