折叠代码返回NA。
as.Date("Thr Jan 15 2015 07:06:04", format = "%a %b %d %Y %T")已经尝试设置系统区域设置,如?as.Date中所述
## read in date info in format 'ddmmmyyyy'
## This will give NA(s) in some locales; setting the C locale
## as in the commented lines will overcome this on most systems.
## lct <- Sys.getlocale("LC_TIME"); Sys.setlocale("LC_TIME", "C")
x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960")
z <- as.Date(x, "%d%b%Y")
## Sys.setlocale("LC_TIME", lct)发布于 2015-03-30 10:21:21
周四的缩写是Thu。所以,也许这应该有效
as.Date('Thu Jan 15 2015 07:06:04', format= '%a %b %d %Y %T')
# [1] "2015-01-15"如果字符串中有typos,则使用sub删除工作日部分
as.Date(sub('[^ ]+ ', '', str1), format= '%b %d %Y %T')
#[1] "2015-01-15"https://stackoverflow.com/questions/29343516
复制相似问题