Re: [R] mean-aggregate – but use unique for factor variables

2012-09-25 Thread Bert Gunter
In the absence of data via dput() or other wise I would assume that if you made your function FUN something like: function(x) if(is.factor(x)) unique(x) else mean(x) (or maybe length(unique(x)) as first clause) you'd get what you want. No? On Tue, Sep 25, 2012 at 2:32 PM, Martin Batholdy

[R] mean-aggregate – but use unique for factor variables

2012-09-25 Thread Martin Batholdy
Hi, I have a data.frame which I want to aggregate. There are some grouping variables and some continuous variables for which I would like to have the mean. However there are also some factor-variables in the data-frame that are not grouping variables and I actually would like to aggregate these