R Programming Questions and Answers – Data Wrangling – 2

This set of Basic R Programming Interview questions and answers focuses on “Data Wrangling – 2”.

1. __________ is used when you have variables that form rows instead of columns.
a) tidy()
b) spread()
c) separate()
d) gather()
View Answer

Answer: b
Explanation: You need spread() less frequently than gather() or separate().

2. Point out the correct statement?
a) tidyr and dplyr packages do not make use of the pipe operator
b) tidyr does less than reshape2
c) tidyr provides ability to string multiple functions together by incorporating %
d) tidyr does greater than reshape2
View Answer

Answer: b
Explanation: Just as reshape2 did less than reshape, tidyr does less than reshape2.

3. Which of the following merges two variables into one?
a) spread()
b) gather()
c) separate()
d) unite()
View Answer

Answer: b
Explanation: The unite() function is a convenience function to paste together multiple variable values into one.


4. How many functions exist for wrangling the data with dplyr package?
a) one
b) seven
c) three
d) five
View Answer

Answer: b
Explanation: dplyr provides seven main functions for tidying your messy data.

5. Point out the correct statement?
a) gather() makes “long” data wider
b) tidyr is a reframing of reshape designed to accompany the tidy data framework
c) there are two fundamental verbs of data tidying
d) tidyr and dplyr packages do not make use of the pipe operator
View Answer

Answer: c
Explanation: In particular, built-in methods only work for data frames, and tidyr provides no margins or aggregation.

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

6. ________ add new variables/columns or transform existing variables.
a) mutate
b) add
c) apped
d) arrange
View Answer

Answer: a
Explanation: arrange is used to reorder rows of a data frame.

7. _________ extract a subset of rows from a data frame based on logical conditions.
a) rename
b) filter
c) set
d) subset
View Answer

Answer: a
Explanation: rename is used to rename variables in a data frame.


8. Spread function is known as ___________ in spreadsheets.
a) pivot
b) unpivot
c) cast
d) order
View Answer

Answer: b
Explanation: Spread is known by other names in other places: it’s cast in reshape2, unpivot in spreadsheets and unfold in databases.

Sanfoundry Global Education & Learning Series – R Programming Language.


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

To practice basic questions on all areas of R Programming, 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]

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.