0
0
R Programmingprogramming~5 mins

separate and unite in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the separate() function do in R's tidyr package?
It splits one column into multiple columns based on a separator, like splitting a full name into first and last names.
Click to reveal answer
beginner
What is the purpose of the unite() function in R?
It combines multiple columns into one column by joining their values with a separator, like merging first and last names into a full name.
Click to reveal answer
intermediate
Which argument in separate() controls the character used to split the column?
The sep argument specifies the separator character or regular expression to split the column.
Click to reveal answer
intermediate
How do you prevent separate() from dropping the original column after splitting?
Use the argument remove = FALSE to keep the original column in the data frame.
Click to reveal answer
intermediate
What happens if you use unite() with remove = FALSE?
The original columns are kept along with the new united column, so no data is lost.
Click to reveal answer
What does separate() do in R's tidyr package?
AFilters rows based on a condition
BCombines multiple columns into one
CSplits one column into multiple columns
DSorts data frame rows
Which argument in unite() sets the character between combined values?
Ainto
Bremove
Cfill
Dsep
If you want to keep the original columns after using unite(), which argument should you use?
Aremove = FALSE
Bkeep = TRUE
Cpreserve = TRUE
Dretain = FALSE
What type of value does the sep argument accept in separate()?
ALogical TRUE or FALSE
BCharacter string or regular expression
CData frame
DNumeric index
Which package provides the separate() and unite() functions?
Atidyr
Bggplot2
Cdplyr
Dstringr
Explain how you would split a column of full names into first and last names using R.
Think about the separator between first and last names.
You got /4 concepts.
    Describe how to combine two columns, like city and state, into one column in R.
    Consider how to join values with a character.
    You got /4 concepts.