I have the following line in my R
code:
pipeline=sprintf("cut -f %i-%i %s", jcol1, jcol2, fname)
Ys <- as.matrix(read.table(pipe(pipeline)))
which takes about 3 seconds. Now, when I hardcode the associated cut
line into my Linux
terminal and pipe to /dev/null
as:
time cut -f 2-5000 filename.txt > /dev/null
I find that this takes 0.631 seconds which tells me that it does not take long to actually read the file.
What aspect of my R
code is taking so long and how can I improve the speed on this?