Stumped on easiest way to append a current year column (only has last two digits 21, 22, 23) to include first two digits (in this case only "20"). I've tried str_glue and past0("20", variable) but had no luck. Any functions/help would be super appreciated. Also, the current year column is in a character type, not a date currently.
test <- tibble(rep= "John Smith", quarter= "q2", year= 19:23, ideal_year= 2019:2023) %>% mutate(year=as.character(year))
CodePudding user response:
Easiest way seems to be:
tibble(rep= "John Smith", year= 19:23, ideal_year= 2019:2023) %>%
mutate(
year = year 2000
)
# A tibble: 5 x 3
rep year ideal_year
<chr> <dbl> <int>
1 John Smith 2019 2019
2 John Smith 2020 2020
3 John Smith 2021 2021
4 John Smith 2022 2022
5 John Smith 2023 2023