250+ TOP MCQs on Data Types and Answers

R Programming Language Multiple Choice Questions on “Data Types”.

1. Which function is used to combine the elements into a vector?
a) C()
b) D()
c) E()
d) F()

Answer: a
Clarification: When you want to create a vector with more than one element, you should use c() function which means to combine the elements into a vector. We can Identify elements of a list using the [[]] convention.

2. A __________ is an R-object which can contain many different types of elements inside it.
a) Vector
b) Lists
c) Matrix
d) Functions

Answer: b
Clarification: A list is an R-object which can contain many different types of elements in it like vectors, functions and even another list inside it. We can Identify elements of a list using the [[]] convention.

3. A _________ is a two-dimensional rectangular data set.
a) Vector
b) Lists
c) Matrix
d) Functions

Answer: c
Clarification: A matrix is a two-dimensional rectangular data set. It can be created using the vector input to a matrix function. The labels are always character irrespective of whether it is numeric or character and also Boolean etc in the vector.

4. Which function takes a dim attribute which creates the required number of dimensions?
a) Vector
b) Array
c) Matrix
d) Lists

Answer: b
Clarification: The array function takes a dim attribute which creates the required number of dimensions. While matrices are confined to two dimensions, arrays could be of any number of dimensions.

5. Factors are the r-objects which are created using a _________
a) Vector
b) Matrix
c) Lists
d) Array

Answer: a
Clarification: Factors are the r-objects which are created using a vector. It stores the vector with also the distinct values of the elements in the vector as labels. They are useful in statistical modelling.

6. Factors are created using the _______ function.
a) C()
b) Function()
c) Array()
d) Lists()

Answer: b
Clarification: Factors are created using the factor() function. The labels are always character irrespective of whether it is numeric or character or also Boolean etc. in the vector. The nlevels functions will give the count of levels.

7. By what function we can create data frames?
a) Data.frames()
b) Data.sets ()
c) Function ()
d) C ()

Answer: a
Clarification: Data frames are tabular data objects. Unlike a matrix in each data frame every column will contain different modes of data. Data Frames are created using the data.frame() function. It is the list of vectors of same length.

8. vectors can be one of two types namely atomic vectors and _______
a) Matrix
b) Vector
c) Lists
d) Array

Answer: c
Clarification: A vector is the most common and basic data structure in R. Technically, vectors can be one of two types of atomic vectors and lists. Although vector most commonly refers to the atomic types.

9. Lists can be coerced with which function?
a) As.lists
b) Has.lists
c) In.lists
d) Co.lists

Answer: a
Clarification: Lists are sometimes called generic vectors because the elements of a list can be of any type of R object, even lists containing further lists. This property makes them fundamentally different from other atomic vectors. Create lists using list() and coerce other objects using as.list().

10. A data frame is a special type of list where every element of the list has ______ length.
a) Same
b) Different
c) May be different
d) May be same

Answer: a
Clarification: A data frame is a very important data type in R. It’s pretty much the de facto data structure for most tabular data and what we use for statistics. A data frame was a special type of list in which every element of the list has the same length.

11. Data frames can have additional attributes such as __________
a) Rowname()
b) Rownames()
c) R.names()
d) D.names()

Answer: b
Clarification: Data frames can have additional attributes such as rownames(), which can be useful for annotating data, like subject_id or sample_id. But most of the time they are not used. A data frame is an important data type in R.

12. Decimal values are referred as ________ data types in R.
a) Numeric
b) Character
c) Integer
d) Lists

Answer: a
Clarification: Decimal values are referred to as numeric data types in R. Data frames are the tabular data objects. Unlike a matrix in data frame every column can contain different modes of data.

13. Which is the basic data structure of R containing the same type of data?
a) Functions
b) Array
c) Vector
d) Lists

Answer: c
Clarification: Vector is a basic data structure in R that contains an element of similar type. These data types in R can be logical, integer, double, character, complex and also raw. In R using the function, typeof() one can check the data type of vector.

14. In R using the function, ________ one can check the data type of vector.
a) Typeof()
b) Castof()
c) Function()
d) C()

Answer: a
Clarification: In R using the function, typeof() one can check the data type of vector. Vector is a basic data structure in R which contains element of similar type. These data types in R can be logical, integer, double, character, complex and also raw.

15. __________are Data frames which contain lists of homogeneous data in a tabular format.
a) Matrix
b) Vector
c) Lists
d) Array

Answer: c
Clarification: Matrices are Data frames which contain lists of homogeneous data in a tabular format. Technically, vectors can be one of two types of atomic vectors and lists. Although vector is mostly refers to the atomic types.

Leave a Reply

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