Skip to content

Aggregate?

3 messages · Gustaf Rydevik, Ingmar Visser, PIKAL Petr

#
Hi All,

I think i'm failing to undersatnd how aggregate() is supposed to work.

example:

 test1<-sample(c(0,1),100,replace=T)
test2<-sample(letters,100,replace=T)
aggregate(test1,list(test2),sum)
Error in data.frame(w, lapply(y, unlist, use.names = FALSE)) :
        arguments imply differing number of rows: 26, 0

I thought this would give me a list containing the number of ones that
"belong" to each letter. What am I doing wrong?

Thanks in advance,

Gustaf
#
It does that for me without errors ...
(R 2.3.1 on Mac OSX 10.4.8)
Best, Ingmar
#
Hi

look to your workspace by ls(). I bet there is some mismatch in 
variables as your example works for me without any error. You 
probably redefined sum function.
Group.1 x
1        b 1
2        c 3
3        d 1
4        e 4
Error in FUN(X[[1]], ...) : argument "INDEX" is missing, with no 
default

HTH
Petr
On 8 Dec 2006 at 12:58, Gustaf Rydevik wrote:
Date sent:      	Fri, 8 Dec 2006 12:58:01 +0300
From:           	"Gustaf Rydevik" <gustaf.rydevik at gmail.com>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] Aggregate?
Petr Pikal
petr.pikal at precheza.cz