transpose a matrix?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

transpose a matrix?

t c-4
  I have a data set in the following format:
   
  x<-data.frame(id=c(‘a’,’b’,’c’),’2005-01-15’=c(100,225,425), ’2005-02-23’=c(1100,2325,4525))
   
  > x
    id X2005.01.15 X2005.02.23
  1  a         100        1100
  2  b         225        2325
  3  c         425        4525
   
   
  I want:
          id
    a
    b
    c
      X2005.01.15
    100
    225
    425
      X2005.02.23
    1100
    2325
    4525
   
   
  Any Suggestions?


__________________________________________________



        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: transpose a matrix?

Uwe Ligges
t c wrote:

>   I have a data set in the following format:
>    
>   x<-data.frame(id=c(‘a’,’b’,’c’),’2005-01-15’=c(100,225,425), ’2005-02-23’=c(1100,2325,4525))
>    
>   > x
>     id X2005.01.15 X2005.02.23
>   1  a         100        1100
>   2  b         225        2325
>   3  c         425        4525
>    
>    
>   I want:
>           id
>     a
>     b
>     c
>       X2005.01.15
>     100
>     225
>     425
>       X2005.02.23
>     1100
>     2325
>     4525
>    
>    
>   Any Suggestions?


I do not get your point, since subject line and body of your message are
telling different stories. Do you want to have a list of vectors?

You certainly do not want to transpose a data frame with both factors
(or character) and numeric values in it.....

Uwe Ligges



>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: transpose a matrix?

David Ruau-2
In reply to this post by t c-4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you want from the explanation you gave but to transpose
try that:
x <- as.matrix(x)
x.trans <- t(x)

One method that's may also of use is
help.search("transpose")

David
On Dec 20, 2005, at 17:26, t c wrote:

>   I have a data set in the following format:
>
>   x<-data.frame(id=c(‘a’,’b’,’c’),’2005-01-15’=c(100,225,425),
> ’2005-02-23’=c(1100,2325,4525))
>
>> x
>     id X2005.01.15 X2005.02.23
>   1  a         100        1100
>   2  b         225        2325
>   3  c         425        4525
>
>
>   I want:
>           id
>     a
>     b
>     c
>       X2005.01.15
>     100
>     225
>     425
>       X2005.02.23
>     1100
>     2325
>     4525
>
>
>   Any Suggestions?
>
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFDqUsI7EoGVUIQyhERArLdAKCX7FniqohYs646riJopkqs6/rboQCcDBUK
4n9JS+hzHOwLZLc6HKQWJcM=
=U6e6
-----END PGP SIGNATURE-----

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: transpose a matrix?

David Ruau
In reply to this post by t c-4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you want from the explanation you gave but to transpose
try that:
x <- as.matrix(x)
x.trans <- t(x)

One method that's may also of use is
help.search("transpose")

David

On Dec 20, 2005, at 17:26, t c wrote:

>   I have a data set in the following format:
>
>   x<-data.frame(id=c(‘a’,’b’,’c’),’2005-01-15’=c(100,225,425),
> ’2005-02-23’=c(1100,2325,4525))
>
>> x
>     id X2005.01.15 X2005.02.23
>   1  a         100        1100
>   2  b         225        2325
>   3  c         425        4525
>
>
>   I want:
>           id
>     a
>     b
>     c
>       X2005.01.15
>     100
>     225
>     425
>       X2005.02.23
>     1100
>     2325
>     4525
>
>
>   Any Suggestions?
>
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFDqUtZ7EoGVUIQyhERAohmAJ9ASkIETkTvBP7nT8Tr739H7gwWjwCgiBji
LpWmylZvZ6al91b02rrAtGg=
=a98J
-----END PGP SIGNATURE-----

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html