Reading a specific line of a text file in R

I have a tab file in txt format. The question that I have is that if it can go to a specific line, but without using a for loop, for example, if I want to go to the second line, I did the following:

fileName="table.txt" con=file(fileName,open="r") for (i in 1:2){ ctable<-readLines(con,n=1) } 

but I don't want to use a for loop, how can I do this? Thanks

+6
source share
1 answer

Use read.table() and specify the number of skipped lines in the skip argument. Type ?read.table in the console for more information on additional arguments and shells that you can use.

+3
source