Skip to content
Prev 65359 / 398525 Next

reading row vectors from file

Why not simply read it as an csv file, then transpose it. If you also
store it as a data frame, you can use attach() or detach() the object to
the search path whenever you want to access the variables directly.


df <- read.csv( "tmp.txt", header=FALSE, row.names=1 )
df <- data.frame( t( df ) )
df
    freq noise signal pctrcv
V2     0    49     99      5
V3     1    47      0      0
V4     2    48    100      5
V5     3    48      0      0
V6     4    50      0      0
V7     5    47    100      5
V8     6    48      0      0
V9     7    47    100      5
V10    8    46    100     11
V11    9    50      0      0
V12   16    48    100      5
V13   17    54    101      5
V14   18    49    100      5
V15   19    47      0      0
V16   20    49      0      0


attach( df )
pctrcv
 [1]  5  0  5  0  0  5  0  5 11  0  5  5  5  0  0

signal / noise
 [1] 2.020408 0.000000 2.083333 0.000000 0.000000 2.127660 0.000000
2.127660
 [9] 2.173913 0.000000 2.083333 1.870370 2.040816 0.000000 0.000000
On Thu, 2005-03-03 at 12:22 -0900, Ken Irving wrote: