I have a dataframe where I want to separate a column that contains month and year:
library(tidyverse)
df <- data.frame(
month_year = c("Januar / Janvier 1990", "Februar / Février 1990","März / Mars 1990")
)
# df
# month_year
# 1 Januar / Janvier 1990
# 2 Februar / Février 1990
# 3 März / Mars 1990
The following works, but seems quite a bit clunky:
df %>%
separate(month_year, c("month","nothing","nothing2", "year"), sep = " ") %>%
select(-starts_with("nothing"))
# month year
# 1 Januar 1990
# 2 Februar 1990
# 3 März 1990
Is there a more concise option to achieve the same result?