Re: [R] Reshape or Stack? (To produce output as columns)

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 17 Jun 2008 17:46:02 -0500

>> It sounds like something is going wrong with the melting. Could you
>> please include the output of str(original data frame), and
>> str(melted)? (Or even better a small version of your data created
>> with dput)
>

> And this is a str output of the original data frame (first few rows of that
> displayed in the console):
>
> `data.frame': 6 obs. of 720 variables:
> $ -179.75: num -99.9 -99.9 -99.9 -99.9 -99.9 -99.9
> $ -179.25: num -99.9 -99.9 -99.9 -99.9 -99.9 -99.9
> $ -178.75: num -99.9 -99.9 -99.9 -99.9 -99.9 -99.9
> $ -178.25: num -99.9 -99.9 -99.9 -99.9 -99.9 -99.9
> $ -177.75: num -99.9 -99.9 -99.9 -99.9 -99.9 -99.9
>

Oooh, sorry, I thought your original was a matrix. So you should do:

melted <- melt(as.matrix(yourdataframe))

Hadley

-- 
http://had.co.nz/

______________________________________________
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 Tue 17 Jun 2008 - 23:18:45 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 Wed 18 Jun 2008 - 11:31:02 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