Wrapper for Age-Splitting Methods

do_splitting(X, fn = c("beers", "grabill", "sprague"), verbose = TRUE, ...)

Arguments

X

Input data. UN format.

fn

Method to be called from DemoTools. Available alternatives: "beers", "grabill", "sprague".

verbose

Logical value. If TRUE messages are printed as the method is applied. Set verbose = FALSE to silent the function.

...

Other arguments to be passed on to other methods and functions.

Value

A data.frame having the same number of columns as input data. Different numbers of rows. UN format.

Examples


# Example 1 --- Abridged data
P5 <- DDSQLtools.data$Pop5_Egypt_M_DB

W1 <- do_splitting(P5, fn = "beers")
#> Additional (optional) arguments to control the output for the DemoTools::graduate_beers method:
#> AgeInt method johnson
#> Check ?graduate_beers for details and default values.
W2 <- do_splitting(P5, fn = "grabill")
#> Additional (optional) arguments to control the output for the DemoTools::graduate_grabill method:
#> AgeInt
#> Check ?graduate_grabill for details and default values.
W3 <- do_splitting(P5, fn = "sprague")
#> Additional (optional) arguments to control the output for the DemoTools::graduate_sprague method:
#> AgeInt
#> Check ?graduate_sprague for details and default values.

# Example 2 --- 1-year age groups
P1 <- DDSQLtools.data$Pop1_Egypt_M_DB

V1 <- do_splitting(P1, fn = "beers")
#> Additional (optional) arguments to control the output for the DemoTools::graduate_beers method:
#> AgeInt method johnson
#> Check ?graduate_beers for details and default values.
V2 <- do_splitting(P1, fn = "grabill")
#> Additional (optional) arguments to control the output for the DemoTools::graduate_grabill method:
#> AgeInt
#> Check ?graduate_grabill for details and default values.
V3 <- do_splitting(P1, fn = "sprague")
#> Additional (optional) arguments to control the output for the DemoTools::graduate_sprague method:
#> AgeInt
#> Check ?graduate_sprague for details and default values.

select_columns <- c("AgeID", "AgeStart", "AgeMid", "AgeEnd", "AgeLabel",
                    "DataTypeName", "DataTypeID", "DataValue")

W1[, select_columns]
#> # A tibble: 76 × 8
#>    AgeID AgeStart AgeMid AgeEnd AgeLabel DataTypeName   DataTypeID     DataValue
#>    <dbl>    <dbl>  <dbl>  <dbl>    <dbl> <chr>          <chr>              <dbl>
#>  1    NA        0    0.5      1        0 DemoTools::gr… "do_splitting…   823664.
#>  2    NA        1    1.5      2        1 DemoTools::gr… "do_splitting…   796067.
#>  3    NA        2    2.5      3        2 DemoTools::gr… "do_splitting…   780842.
#>  4    NA        3    3.5      4        3 DemoTools::gr… "do_splitting…   775144.
#>  5    NA        4    4.5      5        4 DemoTools::gr… "do_splitting…   776126.
#>  6    NA        5    5.5      6        5 DemoTools::gr… "do_splitting…   780813.
#>  7    NA        6    6.5      7        6 DemoTools::gr… "do_splitting…   786360.
#>  8    NA        7    7.5      8        7 DemoTools::gr… "do_splitting…   790307.
#>  9    NA        8    8.5      9        8 DemoTools::gr… "do_splitting…   790844.
#> 10    NA        9    9.5     10        9 DemoTools::gr… "do_splitting…   788100.
#> # … with 66 more rows
V1[, select_columns]
#> # A tibble: 96 × 8
#>    AgeID AgeStart AgeMid AgeEnd AgeLabel DataTypeName   DataTypeID     DataValue
#>    <dbl>    <dbl>  <dbl>  <dbl>    <dbl> <chr>          <chr>              <dbl>
#>  1    NA        0    0.5      1        0 DemoTools::gr… "do_splitting…   824484.
#>  2    NA        1    1.5      2        1 DemoTools::gr… "do_splitting…   796999.
#>  3    NA        2    2.5      3        2 DemoTools::gr… "do_splitting…   781842.
#>  4    NA        3    3.5      4        3 DemoTools::gr… "do_splitting…   776176.
#>  5    NA        4    4.5      5        4 DemoTools::gr… "do_splitting…   777163.
#>  6    NA        5    5.5      6        5 DemoTools::gr… "do_splitting…   781838.
#>  7    NA        6    6.5      7        6 DemoTools::gr… "do_splitting…   787364.
#>  8    NA        7    7.5      8        7 DemoTools::gr… "do_splitting…   791291.
#>  9    NA        8    8.5      9        8 DemoTools::gr… "do_splitting…   791816.
#> 10    NA        9    9.5     10        9 DemoTools::gr… "do_splitting…   789070.
#> # … with 86 more rows