From rpruim at calvin.edu  Fri Mar 23 14:29:07 2018
From: rpruim at calvin.edu (Randall Pruim)
Date: Fri, 23 Mar 2018 13:29:07 +0000
Subject: [Rd] aggregate() naming -- bug or feature
Message-ID: <9187C1DA-5061-4ABD-9D7C-D536BB134BD6@calvin.edu>

In the examples below, the first loses the name attached by foo(), the second retains names attached by bar().  Is this an intentional difference?  I?d prefer that the names be retained in both cases.

foo <- function(x) { c(mean = base::mean(x)) }
bar <- function(x) { c(mean = base::mean(x), sd = stats::sd(x))}
aggregate(iris$Sepal.Length, by = list(iris$Species), FUN = foo)
#>      Group.1     x
#> 1     setosa 5.006
#> 2 versicolor 5.936
#> 3  virginica 6.588
aggregate(iris$Sepal.Length, by = list(iris$Species), FUN = bar)
#>      Group.1    x.mean      x.sd
#> 1     setosa 5.0060000 0.3524897
#> 2 versicolor 5.9360000 0.5161711
#> 3  virginica 6.5880000 0.6358796

?rjp


	[[alternative HTML version deleted]]



[Rd] aggregate() naming -- bug or feature
Randall Pruim