将R字符转换为日期 [英] Convert R character to date
本文介绍了将R字符转换为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下字符串:
date <- "Feb 1964"
我正在尝试使用以下代码将其转换为日期:
I am trying to convert this to a date, using the following code:
new.date <- as.Date(date, format="%b %Y")
NA 返回此处。有人可以好心地解释我如何实现这一目标,并解释我在做错什么..
NA is returned here. Can someone kindly explain how I can achieve this, and explain what I am doing wrong ..
在此先感谢
推荐答案
我认为这可能会满足您的要求。
I think this might do what you want.
date <- "Feb 1964"
date <- "1 Feb 1964"
new.date <- as.Date(date, format="%d %b %Y")
new.date
这篇关于将R字符转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文