
Tidy functions (mainly from dplyr and tidyr) to manipulate data frames
Source:R/tidy_functions.R
tidy_functions.Rd
The Tidyverse defines a coherent set of tools to manipulate
data frames that use a non-standard evaluation and sometimes require extra
care. These functions, like mutate()
or summarise()
are defined in the
{dplyr} and {tidyr} packages. When using variants, like {dtplyr} for
data.frame objects, or {dbplyr} to work with external databases,
successive commands in a pipeline are pooled together but not computed. One
has to collect()
the result to get its final form. Most of the tidy
functions that have their "speedy" counterpart prefixed with "s" are listed
withlist_tidy_functions()
. Their main usages are (excluding less used
arguments, or those that are not compatibles with the speedy "s" counterpart
functions):
group_by(.data, ...)
ungroup(.data)
rename(.data, ...)
rename_with(.data, .fn, .cols = everything(), ...)
filter(.data, ...)
select(.data, ...)
mutate(.data, ..., .keep = "all")
transmute(.data, ...)
summarise(.data, ...)
full_join(x, y, by = NULL, suffix = c(".x", ".y"), copy = FALSE, ...)
left_join(x, y, by = NULL, suffix = c(".x", ".y"), copy = FALSE, ...)
right_join(x, y, by = NULL, suffix = c(".x", ".y"), copy = FALSE, ...)
inner_join(x, y, by = NULL, suffix = c(".x", ".y"), copy = FALSE, ...)
bind_rows(..., .id = NULL)
bind_cols(..., .name_repair = c("unique", "universal", "check_unique", "minimal"))
arrange(.data, ..., .by_group = FALSE)
count(x, ..., wt = NULL, sort = FALSE, name = NULL)
tally(x, wt = NULL, sort = FALSE, name = NULL)
add_count(x, ..., wt = NULL, sort = FALSE, name = NULL)
add_tally(x, wt = NULL, sort = FALSE, name = NULL)
pull(.data, var = -1, name = NULL)
distinct(.data, ..., .keep_all = FALSE)
drop_na(data, ...)
replace_na(data, replace)
pivot_longer(data, cols, names_to = "name", values_to = "value")
pivot_wider(data, names_from = name, values_from = value)
uncount(data, weights, .remove = TRUE, .id = NULL)
unite(data, col, ..., sep = "_", remove = TRUE, na.rm = FALSE)
separate(data, col, into, sep = "[^[:alnum:]]+", remove = TRUE, convert = FALSE)
separate_rows(data, ..., sep = "[^[:alnum:].]+", convert = FALSE)
fill(data, ..., .direction = c("down", "up", "downup", "updown"))
extract(data, col, into, regex = "([[:alnum:]]+)", remove = TRUE, convert = FALSE)
plus the functions defined here under.
Usage
list_tidy_functions()
filter_ungroup(.data, ...)
mutate_ungroup(.data, ..., .keep = "all")
transmute_ungroup(.data, ...)
Arguments
- .data
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See
mutate()
for more details.- ...
Arguments dependent to the context of the function and most of the time, not evaluated in a standard way (cf. the tidyverse approach).
- .keep
Which columns to keep. The default is
"all"
, possible values are"used"
,"unused"
, or"none"
(seemutate()
).
Value
See corresponding "non-t" function for the full help page with
indication of the return values. list_tidy_functions()
returns a list of
all the tidy(verse) functions that have their speedy "s" counterpart, see
speedy_functions.
Note
The help page here is very basic and it aims mainly to list all the
tidy functions. For more complete help, see the {dplyr} or {tidyr}
packages. From {dplyr}, the slice()
and slice_xxx()
functions are not
added yet because they are not available for {dbplyr}. Also anti_join()
,
semi_join()
and nest_join()
are not implemented yet.
From {dplyr}, the slice()
and slice_xxx()
functions are not added yet
because they are not available for {dbplyr}. Also anti_join()
,
semi_join()
and nest_join()
are not implemented yet.
From {tidyr} expand()
, chop()
, unchop()
, nest()
, unnest()
,
unnest_longer()
, unnest_wider()
, hoist()
, pack()
and unpack()
are
not implemented yet.
See also
collapse::num_vars()
to easily keep only numeric columns from a
data frame, collapse::fscale()
for scaling and centering matrix-like objects and data frames.