fread - skip lines starting with certain character - "#"

Dnaiel picture Dnaiel · Sep 20, 2013 · Viewed 21.4k times · Source

I am using the fread function in R for reading files to data.tables objects.

However, when reading the file I'd like to skip lines that start with #, is that possible?

I could not find any mention to that in the documentation.

Answer

malcook picture malcook · Feb 20, 2016

fread can read from a piped command that filters out such lines, like this:

fread("grep -v '^#' filename")