我将 1969 年之前的日期存储为一个字符,并希望将它们更改为日期列。
这是我尝试过的代码
options(chron.year.expand =
function (y, cut.off = 19, century = c(1900, 2000), ...) {
chron:::year.expand(y, cut.off = cut.off, century = century, ...)
}
)
test$construction_date2<-as.Date(chron(format(as.Date(test$construction_date, "%d-%b-%y"),"%d/%m/%Y")))
但我收到警告信息:
Warning message:
In convert.dates(dates., format = fmt, origin. = origin.) :
224 months out of range set to NA
输出:
construction_date contruction_date2
23-MAR-59 2059-03-23
05-JUN-95 1995-06-05
30-MAY-87 1987-05-30
15-JAN-18 NA
01-FEB-68 2068-02-01
谁能告诉我哪里出错了?
可重现的例子;
constuction_date<-c("23-MAR-59","05-JUN-95","30-MAY-87","15-JAN-18","01-FEB-68")
预期结果:
construction_date contruction_date2
23-MAR-59 1959-03-23
05-JUN-95 1995-06-05
30-MAY-87 1987-05-30
15-JAN-18 2018-01-15
01-FEB-68 1968-02-01