read_delim 报错解决 “Warning: 754 parsing failures.”

报错信息如下:
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

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值