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

Bert Gunter gunter.berton at gene.com
Fri Mar 25 18:10:16 CET 2011


It does not appear to have been clearly noted in this thread that one
CANNOT "rotate" a data frame. Data frames are designed to contain
mixed types in their columns, which means that to "rotate" the frame,
the rows would have to be coerced to a single type, thereby most
likely losing the information. So the answer to the question is: read
?data.frame to understand why the question is bogus.

matrices (or arrays) are a single type and can be simply "rotated"
(transposed) by ?t (or more generally have their indices permuted by
?aperm). You would have to manually handle row and column names,
however. See ?dimnames

-- Bert

On Fri, Mar 25, 2011 at 9:52 AM, Knut Krueger <rh at knut-krueger.de> wrote:
> Am 25.03.2011 14:51, schrieb Philipp Pagel:
>>
>> The frame$y2 notation still only works for columns, of course.
>> Maybe, if you tell us some more about your actual analysis,
>> more help can be provided.
>
> Thank,s  but the only question was to use a common notation like for columns
> if the excel sheet was build rotated.
>
> Its more easy for beginners to use the column notation than the row notation
> from a data.frame.
> One solution is to rotate the excel sheet, but than you have multiple data.
> So I was looking for a solution to rotate the data set in R
>
> I think I will explain them the row notation for a data.frame
>
> Thank you Knut
>
> ______________________________________________
> 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.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics



More information about the R-help mailing list