[R] melting a list: basic question

From: baptiste auguie <ba208_at_exeter.ac.uk>
Date: Fri, 25 Jul 2008 15:49:36 +0100

Dear list,

I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below,

> a <- 1:10
> example <- list( data.frame(a=a, b=sin(a)), data.frame(a=a,

> b=cos(a)) )
> melt(example, id = a)

this produces the desired result, where the data.frames have been coerced into one with a common identifier variable "a". However, it seems that if "a" is of mode numeric it is not recognized as an id variable,

> a <- as.numeric(1:10)
> example <- list(data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a)))
> melt(example, id = a) # this does not use a as an id variable

I'm very new to the reshape package, any pointer would be greatly appreciated. I first tried several combinations of merge, do.call, sapply,... but without success.

Many thanks,


Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,

Phone: +44 1392 264187


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 Fri 25 Jul 2008 - 14:52:00 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 Sat 26 Jul 2008 - 02:32:26 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