报错信息如下:
Parsed with column specification:
cols(
ECs = col_character(),
Combine_IDs = col_character(),
compoundIDs = col_logical()
)
Warning: 754 parsing failures.
row col expected actual file
3257 compoundIDs 1/0/T/F/TRUE/FALSE CID:942, '3241_healthy_microbiome_compoundsID.txt'
3258 compoundIDs 1/0/T/F/TRUE/FALSE CID [... truncated]
根据信息定位到是read_delim读入报的错
individuals_microbiome_combined_enzyme <- read_delim( "3214_healthy_microbiome_compoundsID.txt", sep = ""),
delim = "\t") %>%
separate_rows(., compoundIDs, sep = ",")
根据报错信息,read_delim把我的文件第三列判断为logical数据,这才导致后面读入报错。
因为read_delim是根据文件前几列来猜测数据结构,因为我有些行是空值,而有数值的又在后面,所以只需要把guess的行数提高些就可以了,这样第三列就会读入character了
individuals_microbiome_combined_enzyme <- read_delim( "3214_healthy_microbiome_compoundsID.txt", sep = ""),
delim = "\t", guess_max = 50000) %>%
separate_rows(., compoundIDs, sep = ",")
输出信息
Parsed with column specification:
cols(
ECs = col_character(),
Combine_IDs = col_character(),
compoundIDs = col_character()
参考Ref:
https://cran.r-project.org/web/packages/readr/vignettes/readr.html