Q:

r - import data, columns are character spaces

I have a file containing data which I need to import into a dataframe but the setup of the file is quite terrible.
the file I am trying to import is a list of 344 characters (32 colums, 445k rows). Each column is specific range of character spaces.
Column 1 is character spaces 1:2
Column 2 is character spaces 3:6
Column 3 is character spaces 7:20
and so forth.
data example:
the.data <- list("32154The street", "12546The clouds", "23236The jungle")

what I need it to look like
col1   col2   col3
 32    154    The street
 12    546    The Clouds
 23    236    The jungle

What I've tried:
substr(the.data, 1,2)
substr(the.data, 3,6)
substr(the.data, 7,20)

and bind it together
I would like to find a better solution
I also tried to insert commas at the right character spaces, export it as a csv and re-import (or use textConnection) but ran into problems there.

A:

readr in the tidyverse can read fixed width data.
library('tidyverse')

read_fwf(paste(the.data, collapse='\n'), fwf_widths(c(2,3,15)))
#> # A tibble: 3 x 3
#>      X1    X2         X3
#>   <int> <int>      <chr>
#> 1    32   154 The street
#> 2    12   546 The clouds
#> 3    23   236 The jungle

