I have a very large file of which I only need the first element of rows 1, 100001, 200001, which I extract like this:
x1 <- read.csv(filename, nrows = 1, header = F)[1, 1]
x2 <- read.csv(filename, skip = 100000, nrows = 1, header = F)[1, 1]
x3 <- read.csv(filename, skip = 200000, nrows = 1, header = F)[1, 1]
I don't know how reading works, but I assume this forces some unnessesary reading/skipping.
I wonder if I could continue skipping after reading x2
in stead of starting at the beginning of the file again. That would save some time.
I do not want to have the whole file (or the whole first column) in memory (at some point) if I can avoid it.