Re: [R] All possible combinations of functions within a function

2009-11-10 Thread jim holtman
Here is a hint of how you might want to do the first part.  You might
want to study the 'lappy' function

vegList - lapply(c('bray', ..., 'binomial'), function(.method){
vegdist(x, method=.method)
})

clustList - lapply(vegList, function(.dist){
lapply(c('average', ..., 'centroid'), function(.dist){
hclust(.veg, .dist)
})
})

rest left as exercise for the reader.

On Tue, Nov 10, 2009 at 2:05 PM, bikemike42 ml...@tamu.edu wrote:

 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@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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
R-help@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.


Re: [R] All possible combinations of functions within a function

2009-11-10 Thread baptiste auguie
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 ml...@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@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.


__
R-help@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.


Re: [R] All possible combinations of functions within a function

2009-11-10 Thread Michael L. Treglia
Thank you Baptiste and Jim- I look forward to trying these ideas out 
when I have a chance.

Mike

baptiste auguie wrote:

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 ml...@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@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.




  


--
Michael L. Treglia
Graduate Student
Wildlife and Fisheries Sciences
Texas AM University
Lab: (979)862-7245
Cell: (917)841-5603
ml...@tamu.edu
http://people.tamu.edu/~mlt35

__
R-help@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.