R Programming Questions and Answers – Data Types – 1

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

1. R has how many atomic classes of objects?
a) 1
b) 2
c) 3
d) 5
View Answer

Answer: d
Explanation: The most basic type of R object is a vector.

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

Answer: a
Explanation: A vector can only contain objects of the same class.

3. Numbers in R are generally treated as _______ precision real numbers.
a) single
b) double
c) real
d) imaginary
View Answer

Answer: b
Explanation: This means that even if you see a number like “1” or “2” in R, which you might think of as integers, they are likely represented behind the scenes as numeric objects something like “1.00” or “2.00”.

4. If you explicitly want an integer, you need to specify the _____ suffix.
a) D
b) R
c) L
d) K
View Answer

Answer: c
Explanation: Entering 1 in R gives you a numeric object; entering 1L explicitly gives you an integer object.

advertisement
advertisement

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

Answer: b
Explanation: This allows us to represent entities like 1 / 0.

6. Attributes of an object (if any) can be accessed using the ______ function.
a) objects()
b) attrib()
c) attributes()
d) obj()
View Answer

Answer: c
Explanation: Not all R objects contain attributes, in which case the attributes() function returns NULL.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

7. R objects can have attributes, which are like ________ for the object.
a) metadata
b) features
c) expression
d) dimensions
View Answer

Answer: a
Explanation: These metadata can be very useful in that they help to describe the object.

8. Which of the following can be considered as object attribute?
a) dimensions
b) class
c) length
d) all of the mentioned
View Answer

Answer: d
Explanation: All objects in R have an Attribute list.

advertisement

9. 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) 01
d) 00120
View Answer

Answer: b
Explanation: You can also use the vector() function to initialize vectors.

advertisement

10. The ________ function can be used to create vectors of objects by concatenating things together.
a) cp()
b) c()
c) concat()
d) con()
View Answer

Answer: b
Explanation: The simplest such structure is the numeric vector, which is a single entity consisting of an ordered collection of numbers.

Sanfoundry Global Education & Learning Series – R Programming Language.

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

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

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.