R Programming Questions and Answers – Data Types – 5

«
»

This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “Data Types – 5”.

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

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: 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.

advertisement

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

Answer: c
Explanation: 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
View Answer

Answer: b
Explanation: 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.

advertisement
advertisement

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

Answer: a
Explanation: 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()
View Answer

Answer: b
Explanation: 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.

advertisement

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

Answer: a
Explanation: 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
View Answer

Answer: c
Explanation: 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.

advertisement

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

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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.

advertisement

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

Answer: b
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: c
Explanation: 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()
View Answer

Answer: a
Explanation: 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
View Answer

Answer: c
Explanation: 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.

Sanfoundry Global Education & Learning Series – R Programming Language.

Here’s the list of Best Reference Books in R Programming Language .

To practice all areas of R Programming Language, Here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter