<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Caros,<div><br></div><div>estou postando abaixo um loop com o qual estou trabalhando. É longo, mas se vocês olharem para as linhas finais, verão que estou querendo fazer um plot com os resultados. Mas fazendo dessa maneira, enquanto o loop corre, o R vai produzindo um gráfico com só um ponto (referente ao cálculo de 1 corrida do loop) e substituindo-o por outro gráfico a cada corrida do loop.</div><div>Gostaria de plotar todos os resultados do loop num gráfico só, ou seja, a cada corrida do loop se adicionaria um ponto a um mesmo gráfico.</div><div><br></div><div>Como fazer?</div><div><br></div><div>desde já agradeço,</div><div><br></div><div>Vitor</div><div><br></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">counter<span style="color: rgb(0, 0, 0); "> = </span><span style="color: rgb(1, 1, 1); ">1</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; min-height: 17px; "><font class="Apple-style-span" size="3"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3"><span style="color: #c38806">while</span><span style="color: #000000"> (</span>counter<span style="color: #000000"> <= length(</span>MarkerNames<span style="color: #000000">)) {</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>matObs<span style="color: #000000"> = as.matrix(</span>ObsMatD<span style="color: #000000">[[</span>counter<span style="color: #000000">]])</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #020202">ExpGen</span> = matrix(<span style="color: #010101">0</span>, <span style="color: #020202">nrow</span> = nrow(<span style="color: #020202">matObs</span>), <span style="color: #020202">ncol</span> = ncol(<span style="color: #020202">matObs</span>), <span style="color: #020202">dimnames</span> = list(rownames(<span style="color: #020202">matObs</span>), colnames(<span style="color: #020202">matObs</span>)))</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #020202">N</span> = sum(<span style="color: #020202">matObs</span>)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #c38806">for</span>(<span style="color: #020202">i</span> <span style="color: #c38806">in</span> <span style="color: #010101">1</span>:nrow(<span style="color: #020202">ExpGen</span>)) {</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #c38806">for</span>(<span style="color: #020202">j</span> <span style="color: #c38806">in</span> <span style="color: #020202">i</span>:ncol(<span style="color: #020202">ExpGen</span>)) {</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #c38806">if</span>(<span style="color: #020202">i</span>==<span style="color: #020202">j</span>) {</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #020202">ExpGen</span>[<span style="color: #020202">i</span>, <span style="color: #020202">j</span>] = sum(<span style="color: #020202">matObs</span>[<span style="color: #020202">i</span>, ], <span style="color: #020202">matObs</span>[ ,<span style="color: #020202">j</span>])^<span style="color: #010101">2</span>/(<span style="color: #010101">4</span>*<span style="color: #020202">N</span>)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #c38806">else</span> <span style="color: #c38806">if</span>(<span style="color: #020202">i</span>!=<span style="color: #020202">j</span>) {</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #020202">ExpGen</span>[<span style="color: #020202">i</span>, <span style="color: #020202">j</span>] = sum(<span style="color: #020202">matObs</span>[<span style="color: #020202">i</span>, ], <span style="color: #020202">matObs</span>[ ,<span style="color: #020202">i</span>])*sum(<span style="color: #020202">matObs</span>[<span style="color: #020202">j</span>, ], <span style="color: #020202">matObs</span>[ ,<span style="color: #020202">j</span>])/(<span style="color: #010101">2</span>*<span style="color: #020202">N</span>)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><p style="margin: 0.0px 0.0px 0.0px 4.0px; text-indent: -4.0px; font: 13.0px Monaco; min-height: 17.0px"><font class="Apple-style-span" size="3"><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3">print(names(<span style="color: #020202">ObsMatD</span>[<span style="color: #020202">counter</span>]))</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; min-height: 17px; "><font class="Apple-style-span" size="3"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">popNArm<span style="color: #000000"> = FrmNA(</span>pop<span style="color: #000000">[,</span>counter<span style="color: #000000">:(</span>counter<span style="color: #000000"> + </span><span style="color: #010101">1</span><span style="color: #000000">)])</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">Alleles<span style="color: #000000"> = c(</span>popNArm<span style="color: #000000">[,</span><span style="color: #010101">1</span><span style="color: #000000">], </span>popNArm<span style="color: #000000">[,</span><span style="color: #010101">2</span><span style="color: #000000">])</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">AlleleFreq<span style="color: #000000"> = table(</span>Alleles<span style="color: #000000">)/length(</span>Alleles<span style="color: #000000">)</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3"><span style="color: #020202">Hobs</span> = <span style="color: #010101">1</span> - sum(diag(<span style="color: #020202">matObs</span>))/sum(<span style="color: #020202">matObs</span>)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">Hexp<span style="color: #000000"> = </span><span style="color: #010101">1</span><span style="color: #000000"> - sum(</span>AlleleFreq<span style="color: #000000">^</span><span style="color: #010101">2</span><span style="color: #000000">)</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">Fcoef<span style="color: #000000"> = (</span>Hexp<span style="color: #000000"> - </span>Hobs<span style="color: #000000">) / </span>Hexp</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3">names(<span style="color: #020202">Fcoef</span>) = "F"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3">print(<span style="color: #020202">Fcoef</span>)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; min-height: 17px; "><font class="Apple-style-span" size="3"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">NAratio<span style="color: #000000"> = (</span><span style="color: #010101">1</span><span style="color: #000000"> - nrow(</span>popNArm<span style="color: #000000">)/nrow(</span>pop<span style="color: #000000">[,</span>counter<span style="color: #000000">:(</span>counter<span style="color: #000000"> + </span><span style="color: #010101">1</span><span style="color: #000000">)]))</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3">names(<span style="color: #020202">NAratio</span>) = "NA ratio"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3">print(<span style="color: #020202">NAratio</span>)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; min-height: 17px; "><font class="Apple-style-span" size="3"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3"><span style="color: #000000">plot(</span>NAratio <span style="color: #000000">~ </span>Fcoef<span style="color: #000000">, </span>pch <span style="color: #000000">= </span><span style="color: #010101">19</span><span style="color: #000000">)</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; min-height: 17px; "><font class="Apple-style-span" size="3"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; color: rgb(2, 2, 2); "><font class="Apple-style-span" size="3">counter<span style="color: #000000"> = </span>counter<span style="color: #000000"> + </span><span style="color: #010101">1</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 4px; text-indent: -4px; font: normal normal normal 13px/normal Monaco; "><font class="Apple-style-span" size="3">}</font></div></div><div><br></div><div><div apple-content-edited="true">
</div>
<br></div></body></html>