Separates a column containing year groups, such as "1983-1985
", into
two separate columns named year_min
and year_max
by default.
separate_year_groups(data, year_group = year_group, into = c("year_min", "year_max"), sep = "-")
data | A data frame |
---|---|
year_group | The unquoted column containing the |
into | The names of the min year and max year columns (respectively)
into which the minimum and maximum year from |
sep | Characters separating years in |
Other year processors: add_mid_year_groups
,
complete_year_groups
year_groups <- c("1981-1985", "1986-1990", "1991-1995", "1996-2000", "2001-2005", "2006-2010", "2011-2015") dplyr::tibble(year_group = year_groups) %>% separate_year_groups()#> # A tibble: 7 x 3 #> year_group year_min year_max #> <chr> <chr> <chr> #> 1 1981-1985 1981 1985 #> 2 1986-1990 1986 1990 #> 3 1991-1995 1991 1995 #> 4 1996-2000 1996 2000 #> 5 2001-2005 2001 2005 #> 6 2006-2010 2006 2010 #> 7 2011-2015 2011 2015