我正在导入一个csv文件,并试图设置一些数据类型的因素,如下图所示,这是猜测是字符最初。我认为这将有助于设置正确的数据类型时,导入,但我有麻烦的代码。
> ADT_v3 <- read.csv(("ADT.v3.csv"),
+ col_types = cols(
+ pat_enc_csn_id = col_double(),
+ pat_mrn_id = col_double(),
+ PAT_NAME = col_character(),
+ HOSP_ADMSN_TIME = col_time(format = ""),
+ HOSP_DISCH_TIME = col_time(format = ""),
+ ADT_datetime = col_time(format = ""),
+ ADT_event_name = col_factor(levels = c("Admission", "Transfer Out", "Transfer In", "Patient Update", "Census")),
+ location = col_character(),
+ ROOM_ID = col_double(),
+ level_of_care = col_factor(levels = c("NULL", "Floor", "ICU", "Floor with Tele", "Intermediate/Stepdown"))
+ ))
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
unused argument (col_types = list(list(list(), list(), list(), list(""), list(""), list(""), list(c("Admission", "Transfer Out", "Transfer In", "Patient Update", "Census"), FALSE, FALSE), list(), list(), list(c("NULL", "Floor", "ICU", "Floor with Tele", "Intermediate/Stepdown"), FALSE, FALSE)), list(), NULL))
我试图确保代码没有错别字或错误,但......没有任何运气识别的问题。
1条答案
按热度按时间72qzrwbm1#
试试这个:
(only将
read.csv
替换为readr::read_csv
)