[R] Read last line of a file

Joel joda2457 at student.uu.se
Wed May 4 11:17:29 CEST 2011


Hi dear R users.

I got a file that I need to extract the third column (or word) of the last
line of files that has a diffrent amounts of rows.
It works with 

x<-read.tables("file")
x[1,3] 

This returns the proper result but as the files is large this takes time and
uses memory that is just unneccery.

p<-read.table(textConnection(system("tail -1 file",intern=TRUE)))
p[1,3]

This also returns the proper result but then requires the system to be unix
based witch is quite silly if you ask me. Would rather just use R commands.

So Im wondering if anyone of you got a better way of reading the last line
of a file and extracting the third column (or word) of that line.

Best regards
//Joel Damberg



--
View this message in context: http://r.789695.n4.nabble.com/Read-last-line-of-a-file-tp3494963p3494963.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list