I would like to know if there is an easy way to skip characters using the read_fwf from the readr package in R.
For example, modifying one of the examples in the documentation
library(readr)
fwf_sample <- system.file("extdata/fwf-sample.txt", package = "readr")
read_fwf(fwf_sample, fwf_widths(c(2, -3,2, 3)))
throws the error:
Error: Begin offset (2) must be smaller than end offset (-1)
Using the base read.fwf function works just fine however:
read.fwf(fwf_sample, widths = c(2,-3,2,3))
# V1 V2 V3
#1 12 67 890
#2 12 67 890
#3 12 67 890
#4 12 67 890
#5 12 67 890
Is there a way I can mimic this behaviour using readr::read_fwf
?
(I am interested mostly for performance reason).