[R] All possible combinations of functions within a function

baptiste auguie baptiste.auguie at googlemail.com
Tue Nov 10 20:23:31 CET 2009


Hi,

>From what I understand of your code, you might find the following
construct useful,

funs <- c("mean", "sum", "sd", "diff")
x <- 1:10
lapply(funs, do.call, args=list(x))

and then working with lists rather than naming every object
individually. You might find mapply useful too when you have to pass
several parameters.

HTH,

baptiste

2009/11/10 bikemike42 <mlt35 at tamu.edu>:
>
> Dear All,
>
> I wrote a function for cluster analysis to compute cophenetic correlations
> between dissimilarity matrices (using the VEGAN library) and cluster
> analyses of every possible clustering algorithm (SEE ATTACHED)
> http://old.nabble.com/file/p26288610/cor.coef.R cor.coef.R .  As it is now,
> it is extremely long, and for the future I was hoping to find a more
> efficient way of doing this sort of thing.
>
> To give you an outline of the function, first I create the  dissimiarity
> matrices using all possible methods in the VEGAN command "vegdist", then
> create the clusters using all possible algorithms in "hclust" and the
> dissimilarity matrices I crated, then create a table, and in one column,
> list all combinations, and in the other, compute and put the cophenetic
> correlation.
>
> Any help would be appreciated!  I'm pretty new to writing my own functions
> but I see great time-saving potential.
>
> Thanks!
> Mike
> --
> View this message in context: http://old.nabble.com/All-possible-combinations-of-functions-within-a-function-tp26288610p26288610.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