Takes an ato_tbl with aggregate column names (produced by any
ato_* function) and renames columns to match the taxstats
(or taxstats2) 2% microdata sample schema used by Hugh
Parsonage's DRAT package. Enables consistent variable
definitions when moving between aggregate views and microdata
prototyping.
Usage
ato_to_taxstats(df, direction = c("to_taxstats", "from_taxstats"))Details
The bundled schema map (ato_schema_map()) mirrors the
column names from Parsonage's taxstats and taxstats2
packages, which in turn use the ATO Individual Sample File
variable names. Because taxstats is DRAT-distributed and not
on CRAN, this function imposes the mapping as a static table
rather than programmatically introspecting the taxstats
namespace. Re-check the bundled map against the taxstats
NAMESPACE when the ATO publishes a revised Sample File schema.
Unknown columns pass through unchanged. Use
ato_harmonise first if the input panel has drift
in source column names.
References
Parsonage, H. (2019). taxstats: 2 per cent Individual Sample File from the Australian Taxation Office. R package (DRAT). https://github.com/HughParsonage/taxstats
Parsonage, H. (2024). grattan: Perform Common Quantitative Tasks for Australian Analysts. R package version 2026.1.1. https://cran.r-project.org/package=grattan
Australian Taxation Office (2024). Taxation Statistics: Individual Sample File documentation.
See also
Other harmonisation:
ato_crosswalk(),
ato_deflate(),
ato_harmonise(),
ato_per_capita(),
ato_reconcile(),
ato_schema_map()
Examples
df <- data.frame(postcode = "2000", taxable_income = 80000,
medicare_levy = 1600)
ato_to_taxstats(df)
#> Postcode Taxable_Income Medicare_levy
#> 1 2000 80000 1600