Skip to contents

One table verbs

arrange()
Arrange rows by variables
count() tally() add_count() add_tally()
Count observations by group
distinct()
Subset distinct/unique rows
fill()
Fill in missing values with previous or next value
filter()
Return rows with matching conditions
mutate() transmute()
Create or transform variables
pull()
Pull out a single variable
relocate()
Change column order
rename() rename_with()
Rename columns
select()
Subset columns using their names and types
summarise() summarize()
Reduce multiple values down to a single value
slice() slice_head() slice_tail() slice_min() slice_max() slice_sample()
Subset rows by position
unite()
Unite Multiple Columns Into One

Two table verbs

bind_cols() bind_rows()
Efficiently bind multiple data.frames by row and column
anti_join() semi_join()
Filtering joins filter rows from x based on the presence or absence of matches in y:
inner_join() left_join() right_join() full_join()
Mutating Joins
union_all()
Union All

Pivoting

pivot_longer()
Pivot data from wide to long
pivot_wider()
Pivot data from long to wide

Grouping

group_by() ungroup()
Group by one or more variables
group_by_drop_default()
Default value for .drop argument of group_by
group_data() group_rows() group_indices() group_vars() groups() group_size() n_groups()
Grouping metadata
group_split() group_keys()
Split data.frame by groups
n() cur_data() cur_data_all() cur_group() cur_group_id() cur_group_rows() cur_column()
Context dependent expressions
nest_by()
Nest By
with_groups()
Perform an operation with temporary groups

Vector functions

across() if_any() if_all()
Apply a function (or functions) across multiple columns
between()
Do values in a numeric vector fall in specified range?
case_when()
A General Vetorised if()
coalesce()
Find first non-missing element
cummean() cumany() cumall()
Cumulative versions of any, all, and mean
desc()
Descending order
if_else()
Vectorised if
lag() lead()
Compute lagged or leading values
n_distinct()
Count the number of unique values in a set of vectors
na_if()
Convert values to NA
near()
Compare two numeric vectors
nth() first() last()
Extract the first, last or nth value from a vector
recode() recode_factor()
Recode values
replace_na()
Replace missing values
cume_dist() dense_rank() min_rank() ntile() percent_rank() row_number()
Windowed Rank Functions

Selection helpers

group_cols()
Select Grouping Variables
peek_vars()
Peek at variables in the selection context
starts_with() ends_with() contains() matches() num_range() all_of() any_of() everything() last_col()
Select Helpers
where()
Select variables with a function

Piping

`%>%`
Forward-pipe operator

data.frame Display

glimpse()
Get a glimpse of your data

data.frame Attributes

Utilities

lst()
Build a list