[R] [newbie] read row from file into vector
ruipbarradas at sapo.pt
Thu Dec 29 22:43:27 CET 2011
Tom Roche wrote
> summary: how to read a row (not column) from a file into a vector (not a
> data frame)?
> I'm using
> $ lsb_release -ds
> Linux Mint Debian Edition
> $ uname -rv
> 3.0.0-1-amd64 #1 SMP Sun Jul 24 02:24:44 UTC 2011
> $ R --version
> R version 2.14.1 (2011-12-22)
> I'm new to R (having previously used it only for graphics), but have
> worked in many other languages. I've got a CSV file from which I'd like to
> read the values from a single *row* into a vector. E.g., for a file such
> $ head -n 2 ~/data/foo.csv | tail -n 1
> I'd like to be able to populate a vector 'v' s.t. v=5718, ... v=0
> I can't seem to do that with, e.g., read.csv(...) or scan(...), both of
> which seem column-oriented. What am I missing?
> R-help@ mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
If you want the 2nd line it's fast, if you have a large file, cycle through.
View this message in context: http://r.789695.n4.nabble.com/newbie-read-row-from-file-into-vector-tp4243952p4244038.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help