Skip to contents

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"))

Arguments

df

An ato_tbl or data frame.

direction

"to_taxstats" (default, aggregate -> microdata) or "from_taxstats" (microdata -> aggregate).

Value

A data frame with renamed columns. ato_tbl class and provenance attributes preserved.

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.

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