Skip to content

Comparing dcast and reshape

3 messages · David Winsemius, Nutter, Benjamin

#
On Oct 17, 2012, at 2:09 PM, Nutter, Benjamin wrote:

            
The reshape function will "recognize" that the object was created as a  
wide->long reshaping and if you just use this code, you will get back  
the original:

reshape(FullLong)
#
Thanks for the prompt reply, Dr. Winsemius.

reshape(FullLong)  

Will return the original data frame, but that wasn't quite what I wanted.  I wanted to take it to a wider form than the original.

But I just answered my own question (typically, _after_ asking the world at large).

FullWide <- reshape(Raw,
        v.names=c("base.score", "score.90d"),
        timevar="instrument",
        idvar=c("site", "id"),
        direction="wide")

gives me what I was looking for.  I suspect there isn't a way to go directly from FullLong to FullWide, but if someone can prove me wrong, I'd love to see how.

? Benjamin Nutter |??Biostatistician   ? |??Quantitative Health Sciences
? Cleveland Clinic?   | ?9500 Euclid Ave.? | ?Cleveland, OH 44195? |?(216) 445-1365



-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Wednesday, October 17, 2012 5:18 PM
To: Nutter, Benjamin
Cc: r-help at r-project.org
Subject: Re: [R] Comparing dcast and reshape
On Oct 17, 2012, at 2:09 PM, Nutter, Benjamin wrote:

            
The reshape function will "recognize" that the object was created as a  
wide->long reshaping and if you just use this code, you will get back
the original:

reshape(FullLong)