[R] melting a list: basic question
baptiste auguie
ba208 at exeter.ac.uk
Fri Jul 25 16:49:36 CEST 2008
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
_____________________________
Baptiste Auguié
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
More information about the R-help
mailing list