I have a dataframe with many rows like this:

> df
                 X1   X2   X3   X4   X5   X6   X7 week         d
sim1 FALSE TRUE TRUE TRUE TRUE TRUE TRUE    1 0.3064985

sim1 is the rowname, X1..X7,week,d are the column names.  X1..X7 are factors, 
booleans in this case.

I need to add another row, represented by the following list:

list(rep(T,7),5,0.0)

-- i.e, TRUE in all boolean columns, 5 in the week column, 0.0 in d.  The name 
of the new row is "dreps".

I used to add fully numeric rows as follows:

df1 <- rbind(df,dreps=c(<all numbers>))

But if I do this here,

df1 <- rbind(df,dreps=c(rep(T,7),5,0.0)) -- booleans are converted to 0/1, 
which is not what I want.

What's the recommended way to specify and bind a heterogeneous row above?

Cheers,
Alexy
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to