250+ TOP MCQs on Overview of R and Answers

R Programming Language Multiple Choice Questions on “Overview of R”.

1. What will be the output of the following R program?

a) 0
b) 1
c) 2
d) 3

Answer: b
Clarification: 1 is the output of the above code as indexing in R starts from 1. The output can be viewed in the R console. R studio has both R terminal and the R console. Each output format is implemented as a function in R. You can customize the output by passing arguments to the function as sub-values of the output field.

2. Which of the following operator is used to create integer sequences?
a) :
b) ;
c) –
d) ~

Answer: a
Clarification: “:” operator is used to create an integer sequence. The other operators are used for other purposes. Integer sequence is the basic operator used in R. The [ operator can be used to extract multiple elements of a vector by passing the operator an integer sequence.

3. What will be the output of the following R program?

a) Error in vector(y): invalid ‘mode’ argument
b) 1
c) 4
d) 3

Answer: a
Clarification: y is already vector; second line is an invalid argument. The third line will give us the output. When an R vector is printed you will notice that an index for the vector is printed in square brackets
[] on the side.

4. In R language, a vector is defined that it can only contain objects of the ________
a) Same class
b) Different class
c) Similar class
d) Any class

Answer: a
Clarification: A vector can only contain objects of the same class. A vector cannot have contain objects of the different class. Same class objects are used mostly. The most basic type of R object is a vector. Empty vectors can be created with the vector() function.

  250+ TOP MCQs on Exploratory Data Analysis and Answers

5. A list is represented as a vector but can contain objects of ___________
a) Same class
b) Different class
c) Similar class
d) Any class

Answer: b
Clarification: A list can contain objects of different class. But a vector can only contain objects of the same class. A vector cannot have contain objects of the different class. Same class objects are used mostly.

6. How can we define ‘undefined value’ in R language?
a) Inf
b) Sup
c) Und
d) NaN

Answer: d
Clarification: NaN is used to define the “undefined” value in the R language. Undefined values also have some value in R. Missing values are denoted by NA or NaN for q undefined mathematical operations. A NaN value is also NA but the converse is not true.

7. What is NaN called?
a) Not a Number
b) Not a Numeric
c) Number and Number
d) Number a Numeric

Answer: a
Clarification: NaN is called Not a Number. It is the full form of NaN. Full forms can be viewed in R studio by typing help. A NaN value is also NA but the converse is not true. The value NaN represents an undefined value.

8. How can we define ‘infinity’ in R language?
a) Inf
b) Sup
c) Und
d) NaN

Answer: a
Clarification: Inf is used to define “Infinity” in R. It is somewhat different from other programming languages. There is also a special number of Inf which represents infinity.

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

a) [1] “TRUE” “2”
b) [1] “TRUE” 2
c) [1] “0” “2”
d) [1] 1 2

Answer: d
Clarification: Here TRUE is taken as 1. Then it will give output as 1 and 2. FALSE can be taken as 0. T and F are short-hand ways to specify TRUE and FALSE.

  250+ TOP MCQs on Visualizing Data and Answers

10. What is the class defined by the following R code?

a) Character
b) Numeric
c) Logical
d) Integer

Answer: a
Clarification: Here 2 is changed into character. Since the y belongs to list. A list contains only characters. Combining a numeric object with a character object will create a character vector because numbers can usually be easily represented as strings.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top