[R] coercing columns

Liaw, Andy andy_liaw at merck.com
Fri Jan 7 18:31:03 CET 2005


Coercion to matrix then to vector should work:

> dat
  V1 V2 V3
1  A  B  C
2  B  C  A
3  A  A  B
> as.vector(as.matrix(dat))
[1] "A" "B" "A" "B" "C" "A" "C" "A" "B"

Andy

> From: Christoph Scherber
> 
> Dear all,
> 
> I have a data frame that looks like this:
> 
> c1   c2   c3
> A    B    C
> B    C    A
> A    A    B
> 
> and so on;
> 
> I´d like to produce one single vector consisting of the 
> columns c1,c2, 
> c3, such that
> 
> vector=("A","B","A","B","C","A","C","A","B")
> 
> I guess it´s easy to do but I don´t know how...Can anyone help me?
> 
> Thanks a lot!
> Christoph
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list