[R] Making multiple columns to a single column

Joshua Wiley jwiley.psych at gmail.com
Sun Mar 14 00:39:13 CET 2010


Hey Hyo,

Rbind puts each object in a row, just use c(d1, d2, ... d72) to
combine them all together.  If you want it in a matrix
matrix(c(d1,d2,...d72), ncol=1).

Best,

Josh


On Sat, Mar 13, 2010 at 3:30 PM, Hyo Lee <totemo13 at gmail.com> wrote:
> Hi guys,
>
> I have a very simple question.
> I'm trying to make multiple columns to a single column.
>
> For example,
>
> *ttx1* is a 46*72 matrix.
>
> so, I tried this.
>
> *d1=ttx1[,1]
> d2=ttx1[,2]
> ...
> d72=ttx1[,72]*
>
> now, d1, d2, ...,d72 become a 46*1 matrix.
> And then.. I tried..
>
> *dd=rbind(d1, d2, ..., d72)*
>
> I thought *dd* should be 3312*1 matrix; but it becomes 72*46.
> I really wanted to make it a  single column (3312*1).
>
> Do you know what is wrong in this code? Or, do you have a better idea in
> making multiple columns to a single column?
>
> Thank you so much.
>
> -Hyo
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/



More information about the R-help mailing list