R Data Types MCQ

1. Which of the following is a complex data type in R?

a) String
b) Integer
c) Complex
d) Boolean

Answer:

c) Complex

Explanation:

R supports complex numbers as a data type, which includes real and imaginary parts.

2. In R, what data type is used to store textual data?

a) String
b) Char
c) Text
d) Character

Answer:

d) Character

Explanation:

In R, textual data is stored as character data type. There's no specific 'String' or 'Text' data type as in some other programming languages.

3. Which of the following is an atomic data type in R?

a) List
b) Matrix
c) Numeric
d) Data frame

Answer:

c) Numeric

Explanation:

Numeric is an atomic data type in R. Atomic data types include numeric, integer, character, logical, and complex.

4. What data type does the logical value TRUE belong to in R?

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

Answer:

d) Logical

Explanation:

In R, logical values (TRUE and FALSE) are of the logical data type.

5. How are missing values represented in numeric vectors in R?

a) 0
b) ""
c) NA
d) NULL

Answer:

c) NA

Explanation:

In R, missing values in vectors and other data structures are represented by NA (Not Available).

6. What is the data type of the result of the expression 3L in R?

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

Answer:

b) Integer

Explanation:

In R, appending 'L' to a number (e.g., 3L) specifies that it is an integer.

7. Which data type in R is used to store key-value pairs?

a) Vector
b) List
c) Array
d) Data frame

Answer:

b) List

Explanation:

Lists in R can hold key-value pairs, where each element can have a name (key) and associated data (value).

8. What type of object is created by the c() function in R?

a) List
b) Matrix
c) Vector
d) Data frame

Answer:

c) Vector

Explanation:

The c() function in R is used to create vectors by combining values.

9. In R, what is the data type of a variable that holds the value 3.14?

a) Integer
b) Numeric
c) Complex
d) Double

Answer:

b) Numeric

Explanation:

Decimal numbers in R are stored as numeric data type, which is equivalent to double in many other programming languages.

10. What is the data type of an object created by the function matrix() in R?

a) List
b) Array
c) Matrix
d) Data frame

Answer:

c) Matrix

Explanation:

The matrix() function in R creates matrices, which are 2-dimensional arrays.

11. Which of the following R data types is homogeneous?

a) List
b) Data frame
c) Vector
d) Array

Answer:

c) Vector

Explanation:

Vectors in R are homogeneous, meaning all elements must be of the same type.

12. What is the data type of the result of the expression c(TRUE, FALSE)?

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

Answer:

c) Logical

Explanation:

Combining logical values TRUE and FALSE with c() function in R creates a logical vector.

13. What is the data structure used to store datasets with columns of potentially different types in R?

a) List
b) Matrix
c) Array
d) Data frame

Answer:

d) Data frame

Explanation:

Data frames in R are used to store tabular data where each column can be of a different data type.

14. How is a 3-dimensional array represented in R?

a) Using multiple vectors
b) Using a list of matrices
c) Using the array() function with a 3-dimensional extent
d) R does not support 3-dimensional arrays

Answer:

c) Using the array() function with a 3-dimensional extent

Explanation:

3-dimensional arrays in R are created using the array() function with a dimension parameter specifying the extent in each dimension.

15. What is the class of an object created with the letters variable in R?

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

Answer:

c) Character

Explanation:

The letters variable in R is a built-in variable that contains lowercase letters, and it is of the character class.

Leave a Comment

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

Scroll to Top