我有一个数据集“ datesdata”:
# A tibble: 6 x 2
Month Year
<chr> <dbl>
1 Oct 2018 2018
2 Nov 2018 2018
3 Dec 2018 2018
4 Jan 2019 2019
5 Feb 2019 2019
6 Mar 2019 2019
我正在尝试将“月”转换为日期格式,例如:
datesdata$monthdate <- as.Date(datesdata$Month, format="%b %Y")
哪个返回:
# A tibble: 6 x 3
Month Year monthdate
<chr> <dbl> <date>
1 Oct 2018 2018 NA
2 Nov 2018 2018 NA
3 Dec 2018 2018 NA
4 Jan 2019 2019 NA
5 Feb 2019 2019 NA
6 Mar 2019 2019 NA
这是为什么?如何正确将该字段转换为日期?