Skip to content
Prev 306085 / 398506 Next

aggregate help

Thanks.
Why does
id         id      a1      a2
1 10 10, 10, 10 a, a, b x, x, z
2 20     20, 20    b, b    y, y
3 30         30       c       z

work, but

aggregate(z, list(id=z$id),FUN=function(l) {
  t <- sort(table(l),decreasing=TRUE)
  list(length(t),t[1],names(t)[1],t[2],names(t)[2])
  })
   id id a1 a2
1 10  1  2  2
2 20  1  1  1
3 30  1  1  1
Warning message:
In format.data.frame(x, digits = digits, na.encode = FALSE) :
  corrupt data frame: columns will be truncated or padded with NAs
  
does not?
(I do not want to put the whole list of all possible values into the
return value of aggregate because I am afraid of running out of ram)

  
    
Message-ID: <87ehlsk55v.fsf@gnu.org>
In-Reply-To: <1348176277.50987.YahooMailNeo@web142606.mail.bf1.yahoo.com> (arun's message of "Thu, 20 Sep 2012 14:24:37 -0700 (PDT)")