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
c) Data strings
d) Raw data
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 ______
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?
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.
4. Advanced programmers can write ______ code to manipulate R objects.
d) Java Script
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.
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.
6. Functionality of R is divided into a number of __________
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 ______
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.
8. What would be the output of the following code?
x <- (“a”, “b”) as.logical(x)
a) a b
b) “a” “b”
c) 1 1
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.
9. What is the output of the following command?
a <- (“a” , “b”) mode(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?
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.