[R] melting a list: basic question

hadley wickham h.wickham at gmail.com
Sat Jul 26 03:50:25 CEST 2008


On Fri, Jul 25, 2008 at 9:49 AM, baptiste auguie <ba208 at exeter.ac.uk> wrote:
> 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)

You want:

melt(example, id = "a")

i.e. the id argument is a character or numeric vector specifying which
variables to use as id variables.  Your call would be equivalent to

melt(example, id = 1:10)

which clearly is incorrect for your example.

Hadley

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



More information about the R-help mailing list