Re: [R] melting a list: basic question

From: baptiste auguie <ba208_at_exeter.ac.uk>
Date: Fri, 25 Jul 2008 17:59:11 +0100

Given that I cannot arbitrarily change the data to make "a" an integer, can I still use "a" as a grouping variable?

I tried melt(example, id = factor(a)) but it does not work either. Must this change from numeric values to factors be done before applying melt?

Thanks,

baptiste

On 25 Jul 2008, at 16:35, Dieter Menne wrote:

>>
>>
>>> 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
>>
>
> This is the documented behavior: Only integers and factors are used
> for
> grouping, but as.numeric is double, even if 1:10 looks like integers
>
> a <- as.integer(1:10)
> or simply
>
> a <- 1:10
>
> Dieter



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 - 17:01:35 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 Fri 25 Jul 2008 - 18:32:24 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