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

From: Steve Murray <smurray444_at_hotmail.com>
Date: Wed, 18 Jun 2008 09:04:10 +0000

> >> 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))

I've just tried this and unfortunately it only produces a list of the latitude (column name) values from -89.75 to 89.75, without any of the other data:

> dim(melted)

[1] 360 0
> str(melted)

 num[1:360, 0 ]

Is there a way of retrieving the other data?

        [[alternative HTML version deleted]]



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 Wed 18 Jun 2008 - 10:25:56 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 - 10:31:19 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