R Programming Questions and Answers – Console Input and Evaluation – 1

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

Answer: a
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

Answer: c
Explanation: Unlike some other languages, R does not support multi-line comments or comment blocks.

advertisement
advertisement

3. Which of the R following code is example of explicit printing?
a)

> x <- 5 
> x

b)

Note: Join free Sanfoundry classes at Telegram or Youtube
> x <- 5 
> print(x)

c)

advertisement
> x <- "auto" 
> x

d)

advertisement
> x <- "auto" 
> x <- "auto"
View Answer
Answer: b
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

Answer: b
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

Answer: b
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

Answer: a
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

Answer: a
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

Answer: a
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

Answer: b
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

Answer: b
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.

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.