R Programming Language Multiple Choice Questions on “Console Input and Evaluation – 1”.
1. What will be the output of the following R code?
a) 1
b) 2
c) 3
d) 5
Answer: a
Clarification: 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
Answer: c
Clarification: 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)
b)
c)
d)
> x <- "auto" > x <- "auto"
View Answer
Answer: b
Clarification: Print command is used for outputting the value.
4. Files containing R scripts ends with extension ____________
a) .S
b) .R
c) .Rp
d) .SP
Answer: b
Clarification: 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
Answer: b
Clarification: 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”)
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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()
Answer: b
Clarification: 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
Answer: b
Clarification: All objects created during an R session can be stored permanently in a file for use in future R sessions.