1

I have quite a large file, For simplicity say it has 5 columns and 100 rows.

The width of each column is 8 characters long. The eight characters are either numerals, text or tab space.

For example: (this without the '|' character)

|Header 1|Header 2|Header 3|Header 4|Header 5|
|0.123456|A word\t|   word |etcetcet|Lastone |
...

where \t is a tab character which fills in the remaining characters of the column

I want to bring this file into R as a data frame. Tell me, what are my options

I currently receive this error:

> test<-read.table(base, header = T)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 1 did not have 6 elements
In addition: Warning message:
In read.table(base, header = T) :
  incomplete final line found by readTableHeader on 'test.txt'
aeongrail
  • 1,304
  • 1
  • 13
  • 26
  • 3
    Check `read.fwf` function and its `widths` argument. –  Jul 10 '15 at 03:58
  • Ah so close! I forgot to mention that some of the rows were empty. I managed to get there with `test<-read.table(base, header = T, sep = "\t", fill = T)` which surprisingly worked – aeongrail Jul 10 '15 at 04:36

0 Answers0