0

I am importing a .txt fixed-width dataset with 16 columns in R, and am losing ~half of the columns upon read.

Hard to create replicable data but some ss/snippets below:

Quick look at data below. The first screeenshot shows what the top half of the data file looks like. The first column are the colnames and second are just dashes (I used the length of those to figure the fixed width by column).

When I look at the .txt file, the all of the column names show, but only the first half of the values within the columns show. Scrolling down halfway through the data, the second half of the column values show. I assumed this was a display issue. However, reading the data in to R, I see the same thing.

MA.sample<- read.fwf(MA_file,
                     widths= c(20, 23,  18, 200,    11, 21, 39, 23, 100, 50,    50, 100,    100,    50, 50, 18),
                     n = 10,
                     skip = 2)

Resulting data only pulls in first half of column values.

[Resulting read data][1]

Any help appreciated! Glad to clarify as needed.

  • For reference, I've reviewed the following post & others related with no luck: https://stackoverflow.com/questions/46310238/reading-fixed-width-format-data-into-r-with-entries-exceeding-column-width – Jake Schonberger Nov 22 '19 at 18:03
  • Jake, your file appears to have real linked personal identifiable information with names and addresses. Please edit and remove them and replace with samples. I'll need to flag this for mod. review. – ravic_ Nov 22 '19 at 18:21
  • And while you're updating your post, please include the text itself, rather than an image. I know it's long and unwieldy, but that will allow others to [reproduce your issue](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – ravic_ Nov 22 '19 at 18:22
  • Thanks @Ravic_ will do asap – Jake Schonberger Nov 22 '19 at 18:59

0 Answers0