From fa426ada1230795280b48b3b6bc424260be8b991 Mon Sep 17 00:00:00 2001 From: wfmackey Date: Tue, 1 Jun 2021 12:50:13 +1000 Subject: [PATCH] update README --- README.Rmd | 20 ++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/README.Rmd b/README.Rmd index 4207eee..3f24dc7 100644 --- a/README.Rmd +++ b/README.Rmd @@ -201,3 +201,23 @@ h_df %>% mutate(IsHoliday = is_holiday(dates)) ``` +## Parsing income ranges + +The `parse_income_range` function provides some tools for extracting numbers from income ranges commonly used in Australian data. For example: + +```{r} + +parse_income_range("$1-$199 ($1-$10,399)", limit = "lower") +parse_income_range("$1-$199 ($1-$10,399)", limit = "upper") +parse_income_range("$1-$199 ($1-$10,399)", limit = "mid") + +parse_income_range("e. $180,001 or more", limit = "upper") +parse_income_range("e. $180,001 or more", limit = "upper", max_income = 300e3) + + +parse_income_range("Nil income") +parse_income_range("Negative income") +parse_income_range("Negative income", negative_as_zero = FALSE) + +``` + diff --git a/README.md b/README.md index 4b51c2b..807e441 100644 --- a/README.md +++ b/README.md @@ -259,3 +259,31 @@ h_df %>% #> 1 2020-01-01 TRUE #> 2 2020-01-10 FALSE ``` + +## Parsing income ranges + +The `parse_income_range` function provides some tools for extracting +numbers from income ranges commonly used in Australian data. For +example: + +``` r +parse_income_range("$1-$199 ($1-$10,399)", limit = "lower") +#> [1] 1 +parse_income_range("$1-$199 ($1-$10,399)", limit = "upper") +#> [1] 199 +parse_income_range("$1-$199 ($1-$10,399)", limit = "mid") +#> [1] 100 + +parse_income_range("e. $180,001 or more", limit = "upper") +#> [1] NA +parse_income_range("e. $180,001 or more", limit = "upper", max_income = 300e3) +#> [1] 3e+05 + + +parse_income_range("Nil income") +#> [1] 0 +parse_income_range("Negative income") +#> [1] 0 +parse_income_range("Negative income", negative_as_zero = FALSE) +#> [1] NA +```