Skip to content

Getting data in and out

lazy_dt()
Create a "lazy" data.table for use with dplyr verbs
collect(<dtplyr_step>) compute(<dtplyr_step>) as.data.table(<dtplyr_step>) as.data.frame(<dtplyr_step>) as_tibble(<dtplyr_step>)
Force computation of a lazy data.table

Single table verbs

arrange(<dtplyr_step>)
Arrange rows by column values
count(<dtplyr_step>)
Count observations by group
distinct(<dtplyr_step>)
Subset distinct/unique rows
filter(<dtplyr_step>)
Subset rows using column values
group_by(<dtplyr_step>) ungroup(<dtplyr_step>)
Group and ungroup
group_modify(<dtplyr_step>) group_map(<dtplyr_step>)
Apply a function to each group
head(<dtplyr_step>) tail(<dtplyr_step>)
Subset first or last rows
mutate(<dtplyr_step>)
Create and modify columns
transmute(<dtplyr_step>)
Create new columns, dropping old
relocate(<dtplyr_step>)
Relocate variables using their names
rename(<dtplyr_step>) rename_with(<dtplyr_step>)
Rename columns using their names
select(<dtplyr_step>)
Subset columns using their names
slice(<dtplyr_step>) slice_head(<dtplyr_step>) slice_tail(<dtplyr_step>) slice_min(<dtplyr_step>) slice_max(<dtplyr_step>)
Subset rows using their positions
summarise(<dtplyr_step>)
Summarise each group to one row

Two table verbs

tidyr verbs

complete(<dtplyr_step>)
Complete a data frame with missing combinations of data
drop_na(<dtplyr_step>)
Drop rows containing missing values
expand(<dtplyr_step>)
Expand data frame to include all possible combinations of values.
fill(<dtplyr_step>)
Fill in missing values with previous or next value
nest(<dtplyr_step>)
Nest
pivot_wider(<dtplyr_step>)
Pivot data from long to wide
pivot_longer(<dtplyr_step>)
Pivot data from wide to long
replace_na(<dtplyr_step>)
Replace NAs with specified values
separate(<dtplyr_step>)
Separate a character column into multiple columns with a regular expression or numeric locations