[Traminer-users] repeating a command: loop and/or apply function

Jeremy Reynolds jeremyr at uga.edu
Tue Nov 12 14:52:10 CET 2013


Dear Traminer Users,

I am a novice R user, and I could use some advice about how to repeat
commands in R.  I would like to run a clustering command repeatedly with 7
different dissimilarity matrices named diss1vs.hc through diss7vs.hc.  I
tried the loop below, but it does not run properly.  I have also been
reading about the various apply functions in R, but none of the examples I
found so far seem to be doing what I need.  Can you please tell me 1) how I
can make the loop below run and 2) what would be the equivalent (or perhaps
better) solution using one of the apply functions?

Thanks,

Jeremy


for (i in 1:7){
  ward[i]vs <- hclust(as.dist(diss[i]vs.hc), method = "ward", members
= aggbhps.hc$aggWeights)
}

> for (i in 1:7){+   ward[i]vs <- hclust(as.dist(diss[i]vs.hc), method = "ward", members = aggbhps.hc$aggWeights)Error: unexpected symbol in:
"for (i in 1:7){
  ward[i]vs"> }Error: unexpected '}' in "}"




-- 
********************
Dr. Jeremy Reynolds
Associate Professor
Undergraduate Coordinator
Department of Sociology
116 Baldwin Hall
University of Georgia
Athens, GA 30602-1611
Phone: (706) 583-8072
Web: http://uga.edu/soc/people/faculty/reynolds_jeremy.php
Fax: (706) 542-4320
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20131112/50266220/attachment.html>


More information about the Traminer-users mailing list