# R Language Interview Question-Answer Part – 2

R Language Interview Question and – 1

R Language Interview Question and – 3

Q.1 R has how many atomic classes of objects?

A. 1

B. 2

C. 3

D. 5

Ans : 5

Q.2 Point out the correct statement?

A. Empty vectors can be created with the vector() function

B. A sequence is represented as a vector but can contain objects of different classes

C. “raw” objects are commonly used directly in data analysis

D. The value NaN represents undefined value

Ans : Empty vectors can be created with the vector() function

Q.3 Numbers in R are generally treated as _______ precision real numbers.

A. double

B. single

C. real

D. imaginary

Ans : double

Q.4 If you explicitly want an integer, you need to specify the _____ suffix.

A. D

B. R

C. L

D. K

Ans : L

Q.5 Point out the correct statement?

A. The value NaN represents undefined value

B. Number Inf represents infinity in R

C. NaN can also be thought of as a missing value

D. “raw” objects are commonly used directly in data analysis

Ans : Number Inf represents infinity in R

Q.6 Attributes of an object (if any) can be accessed using the ______ function.

A. objects()

B. attrib()

C. attributes()

D. obj()

Ans : attributes()

Q.7 R objects can have attributes, which are like ________ for the object.

B. expression

C. features

D. dimensions

Q.8 Which of the following can be considered as object attribute?

A. dimensions

B. class

C. length

D. all of the mentioned

Ans : all of the mentioned

Q.9 The ________ function can be used to create vectors of objects by concatenating things together.

A. cp()

B. c()

C. concat()

D. con()

Ans : c()

Q.10 What will be the output of the following R code?
> x <- vector(“numeric”, length = 10)
> x

A. 10

B. 0 0 0 0 0 0 0 0 0 0

C. 0 1

D. 00120

Ans : 0 0 0 0 0 0 0 0 0 0

Q.11 Which of the following statement is invalid?

A. x >- c(1+0i, 2+4i)

B. x >- c(TRUE, FALSE)

C. x >- c(T, F)

D. None of the mentioned

Ans : None of the mentioned

Q.12 Point out the correct statement?

A. Use explicit TRUE and FALSE values when indicating logical values

B. rm command is used to remove objects in R

C. R operates on named data structures

D. All of the mentioned

Ans : All of the mentioned

Q.13 What will be the output of the following R code?
> x <- 6
> class(x)

A. “integer”

B. “numeric”

C. “real”

D. “imaginary”

Ans : “numeric”

Q.14 Point out the correct statement?

A. The usual operator, <-, can be thought of as a syntactic shortcut to expression operation

B. Assignment can also be made using the function assignment()

C. Vectors can be used in arithmetic expressions, in which case the operations are performed element by element

D. seq() is used to delete the numbers

Ans : Vectors can be used in arithmetic expressions, in which case the operations are performed element by element

Q.15 Which of the following is invalid assignment?

A. > c(10.4, 5.6, 3.1, 6.4, 21.7) -> x

B. > assign(“x”, c(10.4, 5.6, 3.1, 6.4, 21.7))

C. > x <- c(10.4, 5.6, 3.1, 6.4, 21.7)

D. None of the mentioned

Ans : None of the mentioned

Q.16 What will be the output of the following R code?
> sqrt(-17)

A. -4.02

B. 4.02

C. NaN

D. 3.67

Ans : NaN

Q.17 _______ function returns a vector of the same size as x with the elements arranged in increasing order.

A. sort()

B. orderasc()

C. orderby()

D. sequence()

Ans : sort()

Q.18 Which of the following code constructs vector of length 11?

A. > v <- 3*x + y + 1

B. > v <- 3*x + y + 2

C. > v <- 2*x + y + 1

D. > v <- 2*x + y + 4

Ans : > v <- 2*x + y + 1

Q.19 Find the following type of vector?
a <- c(1,2,5.3,6,-2,4)

A. Numeric

B. Character

C. Integer

D. Logical

Ans : Numeric

Q.20 All columns in a matrix must have the same mode and the _________ length.

A. Different

B. Same

C. May be the same

D. May be different

Ans : Same

Q.21 ___________ provides optional labels with the columns and rows.

A. Disnames

B. Dimnames

C. Denmes

D. Demnesd

Ans : Dimnames

Q.22 ________ are similar to matrices but can have more than two dimensions.

A. Functions

B. Packages

C. Arrays

D. Columns

Ans : Arrays

Q.23 Which is more general than a matrix, in that different columns can have different modes?

A. Data types

B. Data frames

C. Data sets

D. Databases

Ans : Data sets

Q.24 An ordered collection of objects or components are called ________.

A. Data frames

B. Datasets

C. Databases

D. Lists

Ans : Lists

Q.25 The ________ stores the nominal values as a vector of integers in the range of 1 to unique values in the nominal variable.

A. Factor

B. Matrix

C. Lists

D. Functions

Ans : Factor

Q.26 An ordered factor is used to represent an __________.

A. Ordinal variable

B. Simple variable

C. Coordinal variable

D. Biordinal variable

Ans : Ordinal variable

Q.27 On what basis of a variable, OS allocates memory and decides what can be stored in the reserved memory?

A. Data bases

B. Data sets

C. Data types

D. Lists

Ans : Data types

Q.28 The data type of the R-object becomes the data type of the ________.

A. Functions

B. Packages

C. Variables

D. Lists

Ans : Variables

R Language Interview Question and – 1

R Language Interview Question and – 3