[R] Reshape or Stack? (To produce output as columns)
hadley wickham
h.wickham at gmail.com
Wed Jun 18 00:46:02 CEST 2008
>> 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/
More information about the R-help
mailing list