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

灰太狼 2022-11-05 10:50 310阅读 0赞
  1. 报错信息如下:
  2. Parsed with column specification:
  3. cols(
  4. ECs = col_character(),
  5. Combine_IDs = col_character(),
  6. compoundIDs = col_logical()
  7. )
  8. Warning: 754 parsing failures.
  9. row col expected actual file
  10. 3257 compoundIDs 1/0/T/F/TRUE/FALSE CID:942, '3241_healthy_microbiome_compoundsID.txt'
  11. 3258 compoundIDs 1/0/T/F/TRUE/FALSE CID [... truncated]

根据信息定位到是read_delim读入报的错

  1. individuals_microbiome_combined_enzyme <- read_delim( "3214_healthy_microbiome_compoundsID.txt", sep = ""),
  2. delim = "\t") %>%
  3. separate_rows(., compoundIDs, sep = ",")

根据报错信息,read_delim把我的文件第三列判断为logical数据,这才导致后面读入报错。

因为read_delim是根据文件前几列来猜测数据结构,因为我有些行是空值,而有数值的又在后面,所以只需要把guess的行数提高些就可以了,这样第三列就会读入character了

  1. individuals_microbiome_combined_enzyme <- read_delim( "3214_healthy_microbiome_compoundsID.txt", sep = ""),
  2. delim = "\t", guess_max = 50000) %>%
  3. separate_rows(., compoundIDs, sep = ",")

输出信息

  1. Parsed with column specification:
  2. cols(
  3. ECs = col_character(),
  4. Combine_IDs = col_character(),
  5. compoundIDs = col_character()

参考Ref:

https://cran.r-project.org/web/packages/readr/vignettes/readr.html

发表评论

表情:
评论列表 (有 0 条评论,310人围观)

还没有评论,来说两句吧...

相关阅读