[Rd] Zero-length 'by' in 'aggregate.data.frame'
Suharto Anggono Suharto Anggono
suharto_anggono at yahoo.com
Wed Nov 21 07:54:45 CET 2012
Use of tapply() with a 0-length INDEX list is made deprecated in R 2.15.2. How about the similar case for 'aggregate.data.frame', i.e. 0-length 'by' list? Is it going to be supported or not?
In R 2.15.2, it doesn't work if 'by' does not have names, but works if 'by' has names. If 0-length 'by' does not have names, the code
names(by) <- paste("Group", seq_along(by), sep = ".")
fails to give names, because the result of
paste("Group", seq_along(by), sep = ".")
is "Group.", which has length 1 instead of 0.
> aggregate(data.frame(x=1:10), list(), length)
Error in aggregate.data.frame(data.frame(x = 1:10), list(), length) :
'names' attribute  must be the same length as the vector 
+ structure(list(), names=character(0)), length)
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)
 LC_COLLATE=English_United States.1252
 LC_CTYPE=English_United States.1252
 LC_MONETARY=English_United States.1252
 LC_TIME=English_United States.1252
attached base packages:
 stats graphics grDevices utils datasets methods base
More information about the R-devel