【发布时间】:2018-04-29 22:18:55
【问题描述】:
我有一个数据框列表,其中 6 个数据框中的每一个中有 8 个变量。第 5 个变量是日期,我想使用 lubridate 将其从类字符转换为日期。日期的格式为 dd-mmm-yy。目前我正在使用
firstOfMonth <- lapply(fileList,function(x) { x[5] <-
as.Date(strftime(x, format="%d-%b-y"))
})
但出现以下错误。
Error in as.POSIXlt.default(x, tz = tz) :
不知道如何将“x”转换为“POSIXlt”类
另外,我想将第 8 列的类更改为数字。以下没有成功。
lapply(listDF, function(df) mutate_at(df, vars(matches("^Amount")), as.numeric))
Name Address City District Date Visit Completed Amount
Baxter 1211 South Ave Akron A 4-Mar-22 Y Y 12.02
Christ 105 Main Str Akron B 4-Mar-22 Y N 0
Matthews 152 5th Str Akron A 4-Mar-22 N N 0
James 45 River Rd Akron C 4-Mar-22 Y Y 24.25
Lewis 92 Washington Str Akron D 4-Mar-22 Y Y 16.5
【问题讨论】:
-
您能否提供其中一个数据框的数据样本?