My R cheatsheet

data.table DescriptionR command(Stata command)Produce freq. table by groupdt tab groupCompute max of var per groupdt by group: g r_id = _n lubridate (w/ data.table) DescriptionR commandCreate Date from stringdt Convert Date to year-quarterdt[, yq := quarter(date_var, with_year=TRUE)Create Date from components (e.g., year-quarter from year and quarter)yq = quarter(parse_date_time(paste0(year,...