I have a data set with a character column for months (MONTH
) and a numeric column indicating years (YEAR
). In order to work with it as panel data, I ne
Combining Tim's response with an easy to use date package lubridate
we get:
# This can handle months of JAN, FEB, ETC. Or it can handle months of 01,02,etc.
df$TIME <- lubridate::ymd(paste0(df$YEAR,df$MONTH,"01"))
# or if you need it in MM-YYYY format:
df$TIME <- format(lubridate::ymd(paste0(df$YEAR,df$MONTH,"01")), "%m-%Y")