R Programming Questions and Answers – Data Types – 4

«
»

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

1. Find the following type of vector?

advertisement
a <- c(1,2,5.3,6,-2,4)

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

Answer: a
Explanation: The labels are always character irrespective of whether it is numeric or character and also Boolean etc. on the input vector. The nlevels functions will give the count of levels. Factors are created using the factor() function.
advertisement
advertisement

2. 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
View Answer

Answer: b
Explanation: All columns in a matrix must have the same mode(numeric, character, etc) and also the same length. byrow=TRUE indicates that the matrix should be filled by rows. byrow=FALSE indicates that the matrix should be filled by columns (the default).

3. ___________ provides optional labels with the columns and rows.
a) Disnames
b) Dimnames
c) Denmes
d) Demnesd
View Answer

Answer: b
Explanation: byrow=TRUE indicates that the matrix should be filled by rows. byrow=FALSE indicates that the matrix should be filled by columns (the default). dimnames provides optional labels with the columns and rows.
advertisement

4. ________ are similar to matrices but can have more than two dimensions.
a) Functions
b) Packages
c) Arrays
d) Columns
View Answer

Answer: c
Explanation: Arrays are similar to matrices which can have more than two dimensions. See help(array) for details. Factors are created using the factor() function. We can Identify elements of a list using the [[]] convention.

5. 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
View Answer

Answer: c
Explanation: A data frame is more general than a matrix, in that different columns can have different modes (numeric, character, factor, etc). This is similar to SAS and SPSS datasets. There are many ways to identify the elements of a data frame.
advertisement

6. An ordered collection of objects or components are called ________
a) Data frames
b) Datasets
c) Databases
d) Lists
View Answer

Answer: d
Explanation: An ordered collection of objects are called lists. A list allows you to gather a variety of (possibly unrelated) objects under one name. We can Identify elements of a list using the [[]] convention.

7. 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
View Answer

Answer: a
Explanation: The factor stores the nominal values as a vector of integers in the range [1… k] (where k is the no. of unique values of the nominal variable), and an internal vector of character strings (the original values) mapped to these integers.
advertisement

8. An ordered factor is used to represent an __________
a) Ordinal variable
b) Simple variable
c) Coordinal variable
d) Biordinal variable
View Answer

Answer: a
Explanation: An ordered factor is used to represent an ordinal variable. R will treat factors as nominal variables and also ordered factors as ordinal variables in statistical procedures and graphical analyses.

9. 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
View Answer

Answer: c
Explanation: Based on the data type of a variable, the OS allocates the memory and decides what can be stored on the reserved memory. This means that when you create a variable you reserve some space in memory.

10. The data type of the R-object becomes the data type of the ________
a) Functions
b) Packages
c) Variables
d) Lists
View Answer

Answer: c
Explanation: In R, the variables are not declared as some data type. The variables are assigned with R-Objects and the data type of the R-object will become the data type of the variable. There are many types of R-objects.

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