read.csv Read Specific Row

Outrigger picture Outrigger · Jul 2, 2013 · Viewed 36.4k times · Source

How can we read specific rows into R using the read.csv command? Say if I have a CSV file which has 10 rows of data, and I just want to only read the 5th row of data, I tried doing the following but it doesn't seem to be working:

myFile <- "MockData.csv"
myData <- read.csv(myFile, row.names=5)
myData

Thanks!

Answer

Thomas picture Thomas · Jul 2, 2013

Try:

myData <- read.csv(myFile, nrows=1, skip=4)