[R] reading row vectors from file

From: Ken Irving <fnkci_at_uaf.edu>
Date: Fri 04 Mar 2005 - 08:22:53 EST


Hi,

New to R, using version 2.0.1 (2004-11-15) on debian Linux (sid), kernel 2.6.8-2-686.

I have data in files with separate vectors on each row of the file, e.g.,

$ cat /tmp/stats

    freq,0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,...

    noise,49,47,48,48,50,47,48,47,46,50,48,54,49,47,49,...
    signal,99,0,100,0,0,100,0,100,100,0,100,101,100,0,0,...
    pctrcv,5,0,5,0,0,5,0,5,11,0,5,5,5,0,0,...

I can transpose the data file (e.g., using an awk script), and then read it using read.csv("tstats"),

$ transpose /tmp/stats > /tmp/tstats
$ cat /tmp/tstats

    freq,noise,signal,pctrcv
    0,49,99,5
    1,47,0,0
    2,48,100,5

    ...

but would prefer to import the line-oriented files directly. I've drawn a blank after perusing help, documentation, google searches, etc..

Something like read.csv( "transpose stat |" ) might be nice, e.g., the trailing pipe symbol invokes the argument as a shell pipeline, then reads from stdin, but I'm just making this up... Actually, this does work:

    t <- read.csv( pipe("transpose stat1") )

but it does rely on an external transpose command. Is there a way to read line-oriented vector files directly?

Thanks for any help or leads,   

Ken

-- 
Ken Irving, Research Analyst, fnkci@uaf.edu
Water and Environmental Research Center
Institute of Northern Engineering
University of Alaska, Fairbanks

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Mar 04 09:49:11 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:40 EST