[R] read.xls -> rotate data.frame
David Winsemius
dwinsemius at comcast.net
Fri Mar 25 15:08:10 CET 2011
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
More information about the R-help
mailing list