[R] data.frame extracting data row-wise

Christian Lerch t.c.l at gmx.net
Fri Oct 30 10:42:12 CET 2009


Dear All,

I am struggling with extracting data from a data frame:
x=data.frame(a=1:11,b=100:110)

What I want is a list/vector in this sence: 1 100 2 101 3 102...

For single rows, this works fine:
as.matrix(x)[1,]

For, say 2 rows, this works fine:
z=c(as.matrix(x)[1,],as.matrix(x)[2,])

But
z=c(as.matrix(x)[1:2,])

gives 1 2 100 101!?

Is there an 'automated way' to produce a list/vector from a data frame in which data of each row are just added to the end of the previous row?

Many thanks,
Christian
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!




More information about the R-help mailing list