Skip to contents

Count functions

count_pct()
Count observations with percentage
count_multiple()
Count observations for multiple variables
count_with_total()
Count observations with totals row
count_duplicates()
Count duplicates across specified columns
count_unique()
Count unique values in data frame columns
count_na()
Count NA values by group
crosstab()
Cross-tabulate observations

Grouping and summary functions

summary_report() nom() bin() cont()
Summarize variables based on measurement level
summary_table()
Custom summary table
cols_info()
Get information about data frame columns
df_compare()
Compare two data frames and show differences
group_with_total()
Add "Total" group to grouped dataframe

Data transformation

fct_case_when()
Results of case_when() as factor.
fct_collapse_alt()
Collapse factor levels with additional controls
fct_reorder_n()
Reorder factor levels by sorting along multiple other variables.
reverse_key()
Reverse key a numeric vector
scale_mad()
Scale based on median absolute deviation
scale_vec()
Scaling and centering of vectors
swap() swap_if()
Swap column values, optionally based on condition
try_numeric() try.numeric()
Suppress NA warning when coercing to numeric
winsorize()
Winsorize extreme values

Data restructuring

add_header()
Add header rows to a table
add_empty_rows()
Add empty rows
add_rows_at_value()
Add empty rows at specified values in a column
rev_rows()
Reverse the order of rows in a table.
fct_filter()
Filter by and drop factor levels simultaneously
filter_drop()
Filter by and drop a column simultaneously
group_split_named()
Split dataframe by named groups
pad_vectors()
Pad vectors to the same length
pivot_wider_alt()
Alternative column ordering and naming for pivot_wider()
reorder_dendro_by_label()
Reorder a dendrogram
t_tibble()
Transpose a tibble

Working with missing values

count_na()
Count NA values by group
discard_na()
Remove missing values
find_na_cols() drop_na_cols()
Identify or remove columns with no data
drop_na_rows()
Drop rows where all columns are NA
fct_na_if()
Convert specified factor levels to NA
nth_valid() first_valid() last_valid()
Get the nth, first, or last non-NA value in a vector
is_valid() is.valid()
Identify non-missing values
n_valid() pct_valid() n_pct_valid()
Count non-missing cases
na_if_range()
Set NA values based on range of numbers.
na_to_null() null_to_na()
Replace NA with NULL and vice versa

Working with dates

datetimes_to_date()
Convert all datetimes in table to dates
days_diff()
Number of days between two dates
fiscal_year() ffy() sfy_il() ffyq() sfyq_il()
Get the fiscal year and quarter of a date-time
floor_month() floor_week() floor_days()
Floor methods for date objects
nth_bizday() next_bizday()
Find the nth or next business day
strftime_no_lead()
Format date-time to string without leading zeros

Working with character vectors

glue_chr()
Format and interpolate a string as character vector
str_c_narm()
Concatenate strings with NA handling
str_c_tidy()
Tidy string concatenation
str_collapse()
Collapse a character vector into a single string
str_detect_any() str_starts_any() str_ends_any()
Detect the presence of any pattern in a string
str_prefix() str_suffix()
Find common prefixes or suffixes
syms_to_chr()
Print symbols as a character vector

Statistical functions

se_mean()
Compute the standard error of the mean
se_prop()
Compute the standard error of a proportion
d_to_OR() OR_to_d()
Conversion between Cohen's d and odds ratio
p_to_OR() OR_to_p2() OR_to_p1()
Convert between probabilities and odds ratios
accuracy_stats()
Compute common accuracy and agreement metrics
wkappa()
Compute Cohen's kappa and weighted kappa
cohen_w()
Compute Cohen's w
dunn_test()
Pairwise post-hoc test following Kruskal-Wallis test
asterisks()
Return asterisks corresponding to p-values
ci_sig()
Test whether a confidence interval excludes a given value

Sums, minima, and maxima

sum_if_any() max_if_any() min_if_any()
Sums, maxima and minima with alternative missing value handling
psum() pmean()
Parallel / row-wise sums and means
psum_across() pmean_across() pmin_across() pmax_across()
tidyselect-friendly row-wise aggregation
cumsum_desc()
Descending cumulative sum

Logical tests

is_duplicate()
Identify duplicates within a vector or vectors
is_TRUE() is_FALSE() is_TRUE_or_NA() is_FALSE_or_NA()
Vectorized logical tests
is_coercible_numeric() is_coercible_integer() is_coercible_logical()
Test for data encoded as other formats
is_spss()
Test whether a data frame contains SPSS variable or value labels
eq_shape()
Test if two objects have the same shape

Displaying output

in_excel()
Open dataframe in Excel
print_all()
Print all tibble rows
print_n()
Print specified number of tibble rows
write_xlsx_styled()
Write a styled data frame to an Excel file
add_plot_slide()
Add a plot to a PowerPoint slide

Data visualization helpers

set_ggplot_opts()
Nicer default theme and palettes for ggplot2
add_crossings()
Add crossings to a dataframe for area charts
after_opacity() before_opacity()
Translate colors before and after alpha blending

Working with service cascades

Infix operators

`%<-%` `%->%`
Unpack and assign
`%!in%`
Match values not in vector
`%all_in%` `%any_in%`
Test whether multiple values are in a vector

Miscellany

open_file() open_location() file.open() dir.open()
Open a file or directory
set_compare()
Set comparison with automatic naming
suppress_warnings_if() suppress_messages_if()
Conditionally suppress warnings or messages
untidyselect()
Convert a tidy selection to a vector of column names
zap_everything()
Strip special attributes from SPSS dataset
gain_ss_score()
Compute time period scores for GAIN-SS scales
rbool()
Generate random logicals

Datasets

gain_missing_codes
Missing codes for GAIN ABS
holidays_chestnut
CHS holidays over a 20-year period
holidays_il
Illinois state holidays over a 20-year period
holidays_us
US federal holidays over a 20-year period
state.terr.name state.terr.abb state.terr.data
US state and territory data

Deprecated

get_col_types()
Summarize a dataframe's column types - DEPRECATED
ggview()
Nicer ggplot rendering - DEPRECATED
median_dbl()
Median value as double - DEPRECATED
na_like()
Generate NA values of appropriate type - DEPRECATED
coerce_na_range()
Set NA values based on numbers stored as strings - DEPRECATED
row_sums_spss()
Replicate SPSS SUM() function - DEPRECATED
safe_max() safe_min()
Maxima and minima with alternative missing value handling - DEPRECATED
se()
Compute the standard error - DEPRECATED