Description Usage Arguments See Also Examples
Completes year groups in the data frame with the expected year values,
see fcds_const()
.
1 2 3 |
data |
A data frame |
... |
Ignored if |
year_gt |
Optional earliest year to include (inclusive) |
year_lt |
Optional latest year to include (inclusive) |
year_group |
The unquoted column containing the |
year_group_levels |
The expected year groups that should appear in the data set. If not supplied, the expected year groups from the latest FCDS release will be used instead. |
fill |
Default values for rows in columns added to the data |
Other year processors: add_mid_year_groups
,
separate_year_groups
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | d_year <- tidyr::crossing(
sex = "Female",
race = fcds_const("race"),
year_group = c("1981-1985", "1986-1990", "1991-1995", "1996-2000",
"2001-2005", "2006-2010", "2011-2015")
) %>%
dplyr::mutate(year_group = factor(year_group))
# These two versions are equivalent. The first version completes all variables
# included in the grouping and the second explicitly declares the variables
# that should be completed.
d_year %>%
dplyr::group_by(sex, race) %>%
complete_year_groups() %>%
dplyr::arrange(sex, race, year_group)
d_year %>%
complete_year_groups(sex, race) %>%
dplyr::arrange(sex, race, year_group)
# If you have previously filtered the data to include a subset of years, you
# will likely want to exclude those years from the group completion.
# You can use `year_gt` and `year_lt` to exclude years beyond the boundaries.
d_year %>%
dplyr::filter(!year_group %in% c("1981-1985", "1986-1990")) %>%
complete_year_groups(year_gt = 1990) %>%
dplyr::arrange(sex, race, year_group)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.