【发布时间】:2020-07-13 06:41:40
【问题描述】:
问题/问题
我有 51 列的制表符分隔的 my-data.txt 文件。 col_names 行没有尾随制表符,readr::read_tsv() 正确检测到 51 列。但是,数据列都包含尾随制表符,readr::read_tsv() 将这些错误地解释为具有 52 列。当代码运行时,我收到一个警告,我想摆脱它。是否有任何read_tsv() 参数可以帮助处理这个问题?我应该改用不同的readr 函数吗?
我的数据.txt
PT AU BA CA GP RI OI BE Z2 TI X1 Y1 Z1 FT PN AE Z3 SO S1 SE BS VL IS SI MA BP EP AR DI D2 SU PD PY AB X4 Y4 Z4 AK CT CY SP CL TC Z8 ZB ZS Z9 SN BN UT PM
J Jacquelin, Sebastien; Straube, Jasmin; Cooper, Leanne; Vu, Therese; Song, Axia; Bywater, Megan; Baxter, Eva; Heidecker, Matthew; Wackrow, Brad; Porter, Amy; Ling, Victoria; Green, Joanne; Austin, Rebecca; Kazakoff, Stephen; Waddell, Nicola; Hesson, Luke B.; Pimanda, John E.; Stegelmann, Frank; Bullinger, Lars; Doehner, Konstanze; Rampal, Raajit K.; Heckl, Dirk; Hill, Geoffrey R.; Lane, Steven W. Jak2V617F and Dnmt3a loss cooperate to induce myelofibrosis through activated enhancer-driven inflammation BLOOD 132 26 2707 2721 10.1182/blood-2018-04-846220 DEC 27 2018 2018 10 WOS:000454429300003
J Renne, Julius; Gutberlet, Marcel; Voskrebenzev, Andreas; Kern, Agilo; Kaireit, Till; Hinrichs, Jan; Zardo, Patrick; Warnecke, Gregor; Krueger, Marcus; Braubach, Peter; Jonigk, Danny; Haverich, Axel; Wacker, Frank; Vogel-Claussen, Jens; Zinne, Norman Multiparametric MRI for organ quality assessment in a porcine Ex-Vivo lung perfusion system PLOS ONE 13 12 e0209103 10.1371/journal.pone.0209103 DEC 27 2018 2018 1 WOS:000454418200015
J Lau, Skadi; Eicke, Dorothee; Oliveira, Marco Carvalho; Wiegmann, Bettina; Schrimpf, Claudia; Haverich, Axel; Blasczyk, Rainer; Wilhelmi, Mathias; Figueiredo, Constanca; Boeer, Ulrike Low Immunogenic Endothelial Cells Maintain Morphological and Functional Properties Required for Vascular Tissue Engineering TISSUE ENGINEERING PART A 24 5-6 432 447 10.1089/ten.tea.2016.0541 MAR 2018 2018 4 WOS:000418327100001
代表
请注意,我对 reprex 进行了一些手动编辑,因为我需要读取 .txt 文件以重现问题,但这会导致 reprex 出现错误,而没有我的计算机特定路径)。见RStudio Community Topic 8773
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(readr)
my_data <- read_tsv("my-data.txt", quote = "")
#> Parsed with column specification:
#> cols(
#> .default = col_logical(),
#> PT = col_character(),
#> AU = col_character(),
#> TI = col_character(),
#> SO = col_character(),
#> VL = col_double(),
#> IS = col_character(),
#> BP = col_double(),
#> EP = col_double(),
#> AR = col_character(),
#> DI = col_character(),
#> PD = col_character(),
#> PY = col_double(),
#> TC = col_double(),
#> UT = col_character()
#> )
#> See spec(...) for full column specifications.
#> Warning: 3 parsing failures.
#> row col expected actual file
#> 1 -- 51 columns 52 columns 'my-data.txt'
#> 2 -- 51 columns 52 columns 'my-data.txt'
#> 3 -- 51 columns 52 columns 'my-data.txt'
problems(my_data)
#> # A tibble: 3 x 5
#> row col expected actual file
#> <int> <chr> <chr> <chr> <chr>
#> 1 1 <NA> 51 columns 52 columns 'my-data.txt'
#> 2 2 <NA> 51 columns 52 columns 'my-data.txt'
#> 3 3 <NA> 51 columns 52 columns 'my-data.txt'
由reprex package (v0.3.0) 于 2020-04-01 创建
感谢您抽出宝贵时间帮助我。
【问题讨论】: