【发布时间】:2017-01-12 08:42:48
【问题描述】:
尝试导入包含超过最大整数 (.Machine$integer.max = 2147483647) 的列的数据时,我的代码出现问题。使用 readr 的 read_csv 我相信它是作为 NA 导入的,而不是四舍五入。复杂性来自尝试使用 rbindlist 导入多个 csv。
这是我目前的设置:
load_df_path <- file.path(".../dffolder") #path to folder
df_path_files <- list.files <- (load_df_path, full.names = TRUE) #list files in path
df <- rbindlist(lapply(df_path_files, read_csv)) # read in csvs using readr
如何编写最后一行以导入 csv 并将“数量”列转换为字符而不是整数?
这是我尝试过的一些事情,但没有运气......
## This gets error: Error in switch(tools::file_ext(path)....
df <- rbindlist(lapply(df_path_files, read_csv(df_path_files, col_types = list(amount = col_character()))))
## recreate read_csv and changed col_types = NULL to the above but getting the warning
## Error in FUN(X[[i]], ...) : could not find function "read_delimited"
tl;dr - 在将特定列更改为字符格式或 int64 时需要帮助导入 csv 列表。
谢谢。
【问题讨论】: