【发布时间】:2018-05-25 01:08:51
【问题描述】:
我正在尝试使用dplyr 中的mutate_at() 将类似日期的列强制转换为使用as.Date() 类型的Date 列,但出现错误。代码如下:
library(dplyr)
df = data.frame(date_1 = "7/5/2014", date_2 = "7/22/2011")
df %>%
mutate_at(.vars = c("date_1", "date_2"), .funs = as.Date("%m/%d/%Y"))
这给了我一个错误:Error in charToDate(x): character string is not in a standard unambiguous format
不确定这里发生了什么,因此非常感谢您的帮助。我更喜欢dplyr 解决方案,但如果有更好的方法,我也愿意。
【问题讨论】: