Creates the input for the function life.table
Prepares the input for life.table()
. An individual based approach is supported as well
as already pooled data (e. g. from an already existing life table). In the latter case, the user
has to specify a numerical variable (dec) which defines the count for each age class.
If no life table exists, this function will process a dataframe including the age ranges of
individuals or groups of individuals to discrete the age classes. The age range is spread to
single years. agebeg has to be specified for the beginning of an age range, as well
as ageend for the end of an age range. The method defines in which way the single years between the different age classes are split.
If the data set comprises a grouping variable (e.g., sex), this can be specified with group.
prep.life.table( x, dec = NA, agebeg, ageend, group = NA, method = "Standard", agerange = "included" )
x |
single dataframe containing sex age and quantity of deceased (individuals or group of individuals). |
dec |
numeric vector or a column name (as character) of the count of deceased. |
agebeg |
numeric vector or a column name (as character) for the beginning of an age range. |
ageend |
numeric vector or a column name (as character) for the end of an age range. |
group |
numeric vector or a column name (as character) of the grouping field (e.g., sex),
optional. Default setup is: |
method |
character string, optional. Default options is |
agerange |
character string, optional. Default setup is: |
A list of input parameter needed for the function life.table
.
x or Age: age interval.
a: years within x.
Dx: number of deaths within x.
# Separate age ranges in your data set. df <- dplyr::mutate( tidyr::separate( replace( magdalenenberg, magdalenenberg=="60-x", "60-69" ), a, c("from", "to") ), from = as.numeric(from), to = as.numeric(to) ) # Apply prep.life.table to a data set containing the age ranges. magda_prep <- prep.life.table( df, dec = "Dx", agebeg = "from", ageend = "to", method = "Equal5", agerange = "included" ) # Create a life.table. life.table(magda_prep)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.