Yes, there was a factor... There's one problem left, though... The row names are 1, 11, 111 etc, instead of 1,2,3..."Pascal" == Pascal A Niklaus <[EMAIL PROTECTED]>
on Mon, 08 Dec 2003 11:47:02 +0100 writes:
Pascal> Hi all, is there an easy way to build up a data
Pascal> frame by sequentially adding individual rows?
yes, pretty easy, but usually not recommended because quite inefficient.
rbind() does work with data frames in the cases we know. Have a look at help(rbind.data.frame)
Pascal> The data frame consists of numeric and character Pascal> columns. I thought of rbind, but I ended up with Pascal> numeric values for the character columns.
We'd need to see [i.e give a reproducible example!]
how you "ended up with numeric values for the character
columns" -- which I guess were *factor* instead of character ?
> df <- NULL; > > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > df A B C 1 1 abc 1.3540030 11 1 abc -0.7229597 111 1 abc -0.4922653
Of course, I can do a attr(df,"row.names") <- 1:3 at the end, but is there an easier way? Ideally, I would like to name the row already when adding it to the data frame. Is there another way than setting the row.names attribute "manually" with the attr command?
Pascal
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help