Try with this. You only need year and month, so you can use as.Date()
and format()
to reach what you expect:
#Code
df$date_name <- format(as.Date(df$date),'%b-%Y')
Output:
df
date date_name
1 2020-01-01T05:00:00+0000 Jan-2020
2 2020-02-01T05:00:00+0000 Feb-2020
3 2020-01-01T05:00:00+0000 Jan-2020
4 2020-03-01T05:00:00+0000 Mar-2020
Some data used:
#Data
df <- structure(list(date = c("2020-01-01T05:00:00+0000", "2020-02-01T05:00:00+0000",
"2020-01-01T05:00:00+0000", "2020-03-01T05:00:00+0000")), row.names = c(NA,
-4L), class = "data.frame")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…