<div dir="ltr"><div>Dear Traminer Users,<br><br>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?<br>
<br></div>Thanks,<br><br>Jeremy<br><div><div><br><span class="" style="border-collapse:separate;color:rgb(0,0,0);font-family:'Lucida Console';font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:15px;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(225,226,229)"><pre tabindex="0" class="" style="font-family:'Lucida Console';font-size:10pt!important;outline-style:none;outline-width:initial;outline-color:initial;border-style:none;border-width:initial;border-color:initial;white-space:pre-wrap!important;margin:0px;line-height:1.2">
<br>for (i in 1:7){<br> ward[i]vs <- hclust(as.dist(diss[i]vs.hc), method = "ward", members = aggbhps.hc$aggWeights)<br>}<br><span class="" style="color:blue">
</span><br><span class="" style="border-collapse:separate;color:rgb(0,0,0);font-family:'Lucida Console';font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:15px;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(225,226,229)"><pre tabindex="0" class="" style="font-family:'Lucida Console';font-size:10pt!important;outline-style:none;outline-width:initial;outline-color:initial;border-style:none;border-width:initial;border-color:initial;white-space:pre-wrap!important;margin:0px;line-height:1.2">
<span class="" style="white-space:pre;color:blue">> </span><span class="" style="color:blue">for (i in 1:7){
</span><span class="" style="white-space:pre;color:blue">+ </span><span class="" style="color:blue"> ward[i]vs <- hclust(as.dist(diss[i]vs.hc), method = "ward", members = aggbhps.hc$aggWeights)
</span><span class="" style="color:rgb(197,6,11)">Error: unexpected symbol in:
"for (i in 1:7){
ward[i]vs"
</span><span class="" style="white-space:pre;color:blue">> </span><span class="" style="color:blue">}
</span><span class="" style="color:rgb(197,6,11)">Error: unexpected '}' in "}"</span></pre></span><br><span class="" style="color:rgb(197,6,11)"></span></pre></span><br clear="all"><br>-- <br><div dir="ltr">
********************<br>Dr. Jeremy Reynolds<br>Associate Professor<br>Undergraduate Coordinator<br>Department of Sociology<br>116 Baldwin Hall<br>University of Georgia<br>Athens, GA 30602-1611<br>Phone: (706) 583-8072<br>
Web: <a href="http://uga.edu/soc/people/faculty/reynolds_jeremy.php" target="_blank">http://uga.edu/soc/people/faculty/reynolds_jeremy.php</a><br>Fax: (706) 542-4320</div>
</div></div></div>