[R] Append data to vector form a column of a dataframe

behave dethlef1 at hotmail.com
Wed Oct 12 10:47:57 CEST 2011


Dear R-community,

When doing this:

> test<-data.frame(a=c(1,2,3))
> rbind(test$a, 3)

I expect something like:

> 1
> 2
> 3
> 2

but get:
>     [,1] [,2] [,3]
>[1,]    1    2    3
>[2,]    2    2    2


the same for:

rbind(test[["a"]], 2)
or
rbind(as.vector(test[["a"]]), 2)
or
rbind(t(as.vector(test[["a"]])), 2)

Why is that and how do I extract the "values" from a dataframe to get the
desired result?

Thank you
Dom








--
View this message in context: http://r.789695.n4.nabble.com/Append-data-to-vector-form-a-column-of-a-dataframe-tp3897205p3897205.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list