Reputation: 65
I have txt-files with data arranged in columns, but with a fixed number of textlines (12 in this casee) with comments/general info. I need to remove these textlines (l. 1-12) in order to be able to read the files as a dataframe. Can this be done in R?
Upvotes: 1
Views: 5067
Reputation: 66844
You can use the skip
arugment to read.table:
read.table("file.txt", skip=12)
From the help:
skip
integer: the number of lines of the data file to skip before beginning to read data.
Upvotes: 2
Reputation: 121578
Use skip
argument of read.table
:
read.table(text=' bla
bla
x y
1 2',header=TRUE,skip=2)
x y
1 1 2
Or using readLines
and remove the first 12 rows.
Upvotes: 4