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
Hello,
Not exactly an answer but here it goes.
If you use the formula interface the names will be retained. If fact,
this is even better than those names assigned by bar.
aggregate(Sepal.Length ~ Species, data = iris, FUN = foo)
# Species Sepal.Length
#1 setosa5.006
#2 versico
In the help for ?integrate:
>When integrating over infinite intervals do so explicitly, rather than
just using a large number as the endpoint. This increases the chance of a
correct answer – any function whose integral over an infinite interval is
finite must be near zero for most of that interval
On Fri, Mar 23, 2018 at 6:43 PM, Rui Barradas wrote:
> Hello,
>
> Not exactly an answer but here it goes.
> If you use the formula interface the names will be retained.
Also if you pass named arguments:
aggregate(iris["Sepal.Length"], by = iris["Species"], FUN = foo)
# Species Sepal.Length
Thanks.
I’m aware of the other syntax. My example was just to illustrate the issue
minimally, not to indicate how I am using aggregate(). In my application,
aggregate() will be called within another function, and the information passed
to aggregate() is columns of a matrix returned by model.
I am trying once again.
By just changing
f <- match(xlevs[f], nlevs)
to
f <- match(xlevs, nlevs)[f]
, function 'factor' in R devel could be made more consistent and
back-compatible. Why not picking it?
On Sat, 25/11/17, Suharto Anggono Suharto Anggono