[Rd] Is aggregate() function changing?

Kenneth Roy Cabrera Torres krcabrer at une.net.co
Wed Mar 25 04:10:29 CET 2009


Thank your Dr. Duncan Murdoch:

Yes, you are right! 
I look for a "mean" variable and there it was!!!
It seems to work on the non-patched 2.8.1 version because
I start a new session on a diferent directory, and with
the patched 2.8.1 I use an already created .Rdata where
a "mean" variable exist with a 0 value.

Thank you very much for your help.

Sorry for this silly questions.

Kenneth

El mar, 24-03-2009 a las 07:07 -0400, Duncan Murdoch escribió:
> On 24/03/2009 12:44 AM, Kenneth Roy Cabrera Torres wrote:
> > Hi R developers and debian users:
> > 
> > Finally I found how to work with aggregate() function
> > on the last patched version fo R.
> > 
> > I you use this command it fails:
> >   
> >  aggregate(state.x77, list(Region = state.region), mean)
> > 
> > But if you modify it in this way, it works!:
> > 
> >  aggregate(state.x77, list(Region = state.region), function(x) mean(x) )
> > 
> > Is it necesary to change the example?
> > 
> > What is changing in aggregate() function?
> 
> I get identical results from those, but if I had a local variable (not a 
> function) named "mean", the first one would not work:
> 
>  > mean <- 2
>  > aggregate(state.x77, list(Region = state.region), mean)
> Error in FUN(X[[1L]], ...) : element 1 is empty;
>     the part of the args list of 'is.list' being evaluated was:
>     (INDEX)
> 
> I suspect that is what is going wrong for you.
> 
> Duncan Murdoch
> 
> 
> > 
> > Thank you for your attention.
> > 
> > Kenneth.
> >> sessionInfo()
> > 
> > R version 2.8.1 Patched (2009-03-18 r48193) 
> > x86_64-unknown-linux-gnu 
> > 
> > locale:
> > LC_CTYPE=es_CO.UTF-8;LC_NUMERIC=C;LC_TIME=es_CO.UTF-8;LC_COLLATE=es_CO.UTF-8;LC_MONETARY=C;LC_MESSAGES=es_CO.UTF-8;LC_PAPER=es_CO.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=es_CO.UTF-8;LC_IDENTIFICATION=C
> > 
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> > 
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list