R Programming Questions and Answers – Basics – 3

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

1. A single element of a character vector is referred as ________
a) Character string
b) String
c) Data strings
d) Raw data
View Answer

Answer: a
Explanation: Single element of a character vector is often referred to as a character string. Dates are represented by the Date class and can be coerced from a character string using the as.Date() function. This is a common way to end up with a Date object in R.

2. R files has an extension ______
a) .R
b) .S
c) .Rp
d) .c
View Answer

Answer: a
Explanation: All R files have an extension .R. R provides a mechanism for recalling and re-executing previous commands. All S programmed files will have an extension .S. But R has many functions than S.

3. If the code is stored in the external file, which of the following function is used to call them to a working directory?
a) exec()
b) source()
c) execute()
d) sourcefile()
View Answer

Answer: b
Explanation: source is available in the file menu. Today R runs on almost any standard computing platform and operating system. Its open source nature. The copyright for the primary source code for R is held by the R Foundation and is published under the GNU General Public License version.
advertisement
advertisement

4. Advanced programmers can write ______ code to manipulate R objects.
a) Python
b) Java
c) C
d) Java Script
View Answer

Answer: c
Explanation: C, C++ and Fortran can be linked. There are a number of people had used something like C/C++ programming languages to manipulate the R objects.

5. In ________ Insightful purchased the S language from Lucent for $2 million.
a) 2002
b) 2003
c) 2004
d) 2005
View Answer

Answer: c
Explanation: TIBCO is the current owner of the S language. In 2008, Insightful was acquired by TIBCO for $25 million. As of this writing, TIBCO is the current owner of the S language and is its exclusive developer.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Functionality of R is divided into a number of __________
a) Functions
b) Domains
c) Packages
d) Files
View Answer

Answer: a
Explanation: CRAN hosts many add-on packages that can extend the functionality of R. Connections allow R functions to talk to all different external objects without having to write custom code for each object.

7. Dataframes can be converted into a matrix by calling the following function data ______
a) matr()
b) matrix()
c) matrixf()
d) matrixfunc()
View Answer

Answer: b
Explanation: as.matrix function should be used to coerce a data frame to a matrix. It might seem that the as.matrix() function should be used to coerce a data frame to a matrix.
advertisement

8. What will be the output of the following R code?

       x <- (“a”, “b”)
       as.logical(x)

a) a b
b) “a” “b”
c) 1 1
d) Error
View Answer

Answer: d
Explanation: It is not possible to coerce, so you will get a Warning. Logical creates a logical vector of the specified length. Each element of the vector is equal to FALSE. as.logical attempts to coerce its argument to be of a logical type.
advertisement

9. What will be the output of the following R code?

      a <- (“a” , “b”)
      mode(a)

a) Character
b) Numeric
c) Complex
d) Integer
View Answer

Answer: a
Explanation: Mode of the given command is a character. There are a complementary function writeLines() that takes a character vector and writes each element of the vector one line at a time to a text file.

10. Which of the following is not an object of R?
a) calls
b) expressions
c) strings
d) names
View Answer

Answer: c
Explanation: Calls, expressions and names are the three types of objects that constitute the R language. There is really only one rule about vectors in R, which is that A vector can only contain objects of the same class. R objects can have names, which is very useful for writing readable code and self-describing objects.

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.

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.