[R] Transforming data

jim holtman jholtman at gmail.com
Sun Mar 23 15:18:01 CET 2008


Here are some examples of the transformations that you can do:

> x <- 1:6
> x
[1] 1 2 3 4 5 6
> (z <- matrix(x, ncol=2, byrow=TRUE))
     [,1] [,2]
[1,]    1    2
[2,]    3    4
[3,]    5    6
> as.vector(z)
[1] 1 3 5 2 4 6
> as.vector(t(z))
[1] 1 2 3 4 5 6
>


On Sun, Mar 23, 2008 at 8:12 AM, jenny <jennytimp at hotmail.com> wrote:
>
> My data look like this:
> Col1
> 1
> 2
> 3
> 4
> 5
> 6
> .......
>
> My questions are:
> (1) How do I get it in the following format?
> Col1 Col2
> 1    2
> 3    4
> 5    6
> .......
>
> (2) How do I transform the data in 2 column format above back to the single column format?
>
> Thanks in advance for your reply!
>
>
> _________________________________________________________________
>
>
>        [[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list