Re: [R] read.xls -> rotate data.frame

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Fri, 25 Mar 2011 10:08:10 -0400

On Mar 25, 2011, at 8:49 AM, Knut Krueger wrote:

> Am 25.03.2011 12:56, schrieb Philipp Pagel:
>>
>> OK - in that case you can't fit the data into data.frame. Possibley
>> you cold get what you need using some kind of list structure but I
>> think it's better to ask why you need to transpose the data.
>>
> we have (imported from excel)
>
> frame <-
> data
> .frame
> ("x0
> "=
> c
> ("y1
> ","y2","y3","y4"),"x1"=c(1,2,3,4),"x2"=c(5,6,7,8),"x1"=c(9,10,11,12))
> where y1..yn are the names of the rows
> we need frame$x1 .. . frame$xn
> and frame[1,] .. frame[n,] but the first column is no the rownames.

 > frame2 <- frame[,-1]
 > rownames(frame2) <- frame[,1]
 > t(frame2)
      y1 y2 y3 y4

x1 1 2 3 4
x2 5 6 7 8
x1.1 9 10 11 12

You are the one that provided the funky column names.

>
> if it is possible to rotate the whole dataset we could use
>
> frame$y1 ..frame$y2

-- 

David Winsemius, MD
West Hartford, CT

______________________________________________
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.
Received on Fri 25 Mar 2011 - 14:12:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Mar 2011 - 14:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive