<div dir="ltr">Yuri,<div><br></div><div>Seu <i>loop</i> na variável de indução "city", tem a chamada à write.table no escopo da variável "meses".</div><div><br></div><div>Faça a seguinte correção e veja se os resultados fazem sentido para você:</div><div><br></div><div>.

<div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">#for(e in 1:length(estrategias)){</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">  </div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">  for(m in 1:length(meses)){</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    </div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    a = read.table(paste0(raiz, 'E1\\', meses[m],'\\', 'final.txt'), header = T, sep = '\t')</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    for(city in 1:length(cidade)){</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">      </div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">      for(i in 1:length(anos)){</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">        </div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">        previsao[m,i] = a[city,i]</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">      }</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><b>   # }</b></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><b>    write.table(previsao, paste0(raiz, 'E1\\', cidade[city],'.txt'), row.names = F, col.names = T, sep = '\t')</b></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><b>}</b></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">  }</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">#}</div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">HTH</div>

</div><div>.</div><div>.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-09 16:42 GMT-03:00 Yury Duarte via R-br <span dir="ltr"><<a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Boa tarde colegas listeiros!<div><br></div><div>Estou tendo um pequeno problema para salvar as saídas de um loop que fiz para preencher uma matriz com dados de diferentes arquivos. Meus arquivos base possuem informações anuais de produtividade de 15 locais para um determinado mês. Construí o loop com intenção de gerar um arquivo por local, contemplando as produtividades de cada mês (nas linhas) e de cada ano (nas colunas). Conferi o output do único arquivo salvo pelo script e os valores correspondem ao desejado, então acredito que a lógica para o preenchimento da matriz em branco esteja correta. Os arquivos para executar a simulação estão em anexo e o script está no corpo do email.</div><span class=""><div><br></div><div>Desde já, agradeço pela colaboração de todos!</div><div><br></div><div><div>rm(list = ls())</div><div><br></div><div>raiz = 'C:\\Users\\Yury\\Desktop\\<wbr>Mestrado\\1_TESE\\Model_Data\\<wbr>Maize\\PREVISAO\\PA\\' </div><div><br></div><div>estrategia = c('E1', 'E2', 'E3', 'E4', 'E5')</div><div>meses = c('setembro', 'outubro', 'novembro', 'dezembro', 'janeiro', 'fevereiro', 'marco', 'abril')</div><div>cidade = c("abelardoluz", "altamira", "brasilia", "caarapo", "catalao", "lagarto", "machado", "mateiros",</div><div>           "muitoscapoes", "piracicaba", "pontagrossa", "primaveradoleste", "srmangab", "sdesiderio", "urucui")</div><div>anos = c(1980:2012)</div><div>previsao = matrix(NA, nrow = length(meses), ncol = length(1980:2012))</div><div>colnames(previsao) = 1980:2012</div><div><br></div><div>#for(e in 1:length(estrategias)){</div><div>  </div><div>  for(m in 1:length(meses)){</div><div>    </div><div>    a = read.table(paste0(raiz, 'E1\\', meses[m],'\\', 'final.txt'), header = T, sep = '\t')</div><div>    for(city in 1:length(cidade)){</div><div>      </div><div>      for(i in 1:length(anos)){</div><div>        </div><div>        previsao[m,i] = a[city,i]</div><div>      }</div><div>    }</div><div>    write.table(previsao, paste0(raiz, 'E1\\', cidade[city],'.txt'), row.names = F, col.names = T, sep = '\t')</div><div>  }</div><div>#}</div></div><div><br></div><div><br clear="all"><div><div class="m_-6085021707635859001gmail_signature"><div dir="ltr"><div>Yury Duarte<br></div>Engenheiro Agrônomo - ESALQ/USP<br></div></div></div>
</div></span></div>
<br>______________________________<wbr>_________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/<wbr>cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer" target="_blank">http://www.leg.ufpr.br/r-br-<wbr>guia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div>