I am having a data frame with date variable.
Its format is "2020-09-04". I need this column with 2020-09" year and month field.
I used substr to make this happen, as
substr(data$date,1,7)
got the desired output but the date field changes to character variable.
I tried formatting it using as.date, format but either it is giving me same format or NA when changed to date type. Any help please.