Simulate ages
simulate_age.Rd
Simulate ages
Details
Each data frame must contain 19 rows. The first row represents the total population of all age groups while the next 18 rows represent age groups from 0 to 89 in increments of 5 years.
Examples
# Single data frame
x <- data.frame(AGEGRP = 0:18, TOT_POP = 0)
# populate only age range 40-44, set population total of all ages
x$TOT_POP[c(1, 10)] <- 100
simulate_age(x, 5)
#> [[1]]
#> [1] 44 41 41 41 44
#>
# List of 2 data frames
y <- data.frame(AGEGRP = 0:18, TOT_POP = 0)
# populate age ranges 5-9 and 50-54
y$TOT_POP[c(3, 12)] <- 10
# set population total for all age groups
y$TOT_POP[1] <- sum(y$TOT_POP)
simulate_age(list(x = x, y = y), 15)
#> $x
#> [1] 41 41 40 40 41 42 41 43 40 44 40 40 44 41 40
#>
#> $y
#> [1] 52 5 9 52 53 54 9 5 50 51 52 54 9 5 52
#>