2

I am trying to import a .tab file into R but one of the rows has an unexpected number of elements which gives me an error.

data <- read.table(functions.tab, header = F, sep = "\t")
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 397 did not have 4 elements

What is the best way around this so I don't lose any information? Is there a way to merge the overflow elements into the last column?

Bex
  • 191
  • 1
  • 2
  • 12

1 Answers1

4

We can use the fill argument in read.table for rows that have less number of elements to be filled by NA

data <- read.table(functions.tab, header = F, sep = "\t", fill = TRUE)
akrun
  • 874,273
  • 37
  • 540
  • 662