Skip to contents

Coming from Stata

findit()
Find R equivalents of Stata commands

Inspect variables

browse()
Browse columns like Stata's browse command
codebook()
Inspect a dataset's codebook
misstable()
Tabulate missing values
ds()
List column names by tidyselect
variables() variables_search()
Show the variable list of a dataset
var_type() var_unit()
Report an object's type or unit

Tabulate and summarise

corr()
Calculate complete-case Pearson correlations
pwcorr()
Calculate pairwise correlations
tab() tab1() tab2() fre2() fre() fre1()
Frequency tables and cross-tabulations
summ() tabstat()
Summary statistics

Check and combine data

assert()
Assert that conditions hold
is_first()
Flag the first row of each group
isid() duplicates_report() duplicates_tag() duplicates_list() duplicates_drop()
Check keys and duplicate rows
stata_merge()
Merge two tables with a Stata-style match report

Generate variables

as_dummy() tab_gen()
Create indicator (dummy) variables
xtile() cut_quantile() cut_length() cut_breaks()
Cut a numeric vector into groups
stata_lag() stata_lead() stata_diff()
Calculate panel lags, leads and differences
row_mean() row_sum() row_max() row_min() row_median() row_var() row_sd() row_unique() row_nvals() row_miss() row_non_miss()
Calculate summaries across columns within each row
std() pc() pct()
Standardise a variable or scale it to a percentage

Convert types

mvdecode() mvencode() na_if_value() value_if_na()
Replace values with missing values or fill missing values
destring() decode() tostring() as_character() as_numeric()
Convert vectors for data preparation

Select and preview

select_or_transmute()
Select and compute columns
preview_table() unpreview_table() print_headtail() print_all() print_interval() slice_headtail() slice_interval()
Preview complete tables or select representative rows
varlist()
Select columns with a Stata varlist

Small tools

capture()
Evaluate an expression without stopping on an error
set_seed()
Set the random seed, in a pipeline or alone
timer()
Time an expression
`%>%`
Pass a value through a pipeline

Sample Data

lifeexp
Life expectancy data in 1998