[R] Using Aggregate() with FUN arguments, which require more than one input variables

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Jan 17 19:20:45 CET 2012



On 17.01.2012 18:10, RNoob wrote:
> Dear all,
>
> I am trying to apply the aggregate() function to calculate correlations for
> subsets of a dataframe. My argument x is supposed to consist of 2 numerical
> vectors, which represent x and y for the cor() function.
>
> The following error results when calling the aggregate function: Error in
> FUN(X[[1L]], ...) : supply both 'x' and 'y' or a matrix-like 'x'. I think
> the subsets aggregate puts into cor() are sort of list types and therefore
> can't be handled by cor().


as.matrix() will probably help, but since you have not specified your 
reproducible code, we cannot show how to change that.

Uwe Ligges


> Can anyone provide me with a solution?
>
> Regards,
> RNoob
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Using-Aggregate-with-FUN-arguments-which-require-more-than-one-input-variables-tp4303936p4303936.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list