<div dir="ltr">Oi Éder,<div><br></div><div>primeiramente desculpe pelas mensagens. Não sabia que que elas seriam enviadas, de verdade.Não farei mais isso.</div><div><br></div><div>Em segundo, é que não vou fazer estas correlações só com essas três empresas, mas serão mais que 50. Por isso eu precisava criar um laço para que seja calculada a correlação para cada uma dessas 50 empresas com elas mesmo e entre elas para cada hora fixa. Dei três arquivos só de exemplo.</div><div><br></div><div>Por isso criei um for que "roda" a hora e um outro que "roda" as empresas. Mas acho que quando uso a funçnao paste, ele não intende mais como objeto e sim como string, não sei, posso estar enganada. Porém até agora não achei outro modo de fazer.</div><div><br></div><div>Desculpe novamente pelas mensagens.</div><div><br></div><div>Obrigada,</div><div><br></div><div>Michelle</div></div><div class="gmail_extra"><br><div class="gmail_quote">Em 18 de março de 2015 22:27, Éder Comunello <span dir="ltr"><<a href="mailto:comunello.eder@gmail.com" target="_blank">comunello.eder@gmail.com</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Olá, Michelle!</div><div><br></div><div>Inicialmente gostaria de sugerir que você disponibilizasse os links dos arquivos do Dropbox diretamente no teu script, evitando as diversas mensagens de compartilhamento na lista. </div><div>Para isso você pode consultar o tópico que segue:</div><div><<a href="http://r-br.2285057.n4.nabble.com/R-br-Problema-em-abrir-conexao-com-source-do-Dropbox-Public-tp4662507.html" target="_blank">http://r-br.2285057.n4.nabble.com/R-br-Problema-em-abrir-conexao-com-source-do-Dropbox-Public-tp4662507.html</a>><br></div><div><br></div><div>Quanto ao problema em si, não entendi muito bem, mas deixo um trecho de código que pode te ajudar:</div><div><br></div><div><div><font face="monospace, monospace">### <code r></font></div><div><font face="monospace, monospace">urls1 <- c("<a href="https://www.dropbox.com/s/kgxo3s8qrrv74p3/AAparaCalculodaMedia.txt" target="_blank">https://www.dropbox.com/s/kgxo3s8qrrv74p3/AAparaCalculodaMedia.txt</a>",</font></div><div><font face="monospace, monospace"> "<a href="https://www.dropbox.com/s/fhutciprhgt077x/AIGparaCalculodaMedia.txt" target="_blank">https://www.dropbox.com/s/fhutciprhgt077x/AIGparaCalculodaMedia.txt</a>",</font></div><div><font face="monospace, monospace"> "<a href="https://www.dropbox.com/s/kvubgji1tce8sm8/AXPparaCalculodaMedia.txt" target="_blank">https://www.dropbox.com/s/kvubgji1tce8sm8/AXPparaCalculodaMedia.txt</a>")</font></div><div><font face="monospace, monospace"><br></font></div><div><span style="font-family:monospace,monospace">### alterar links públicos para carregamento direto!</span><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">urls2 <- sub("^.*/s/", "<a href="http://dl.dropbox.com/s/" target="_blank">http://dl.dropbox.com/s/</a>", urls1) </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">AA <- read.table(urls2[1], header=T, <a href="http://as.is" target="_blank">as.is</a>=T)</font></div><div><font face="monospace, monospace">AIG <- read.table(urls2[2], header=T, <a href="http://as.is" target="_blank">as.is</a>=T)</font></div><div><font face="monospace, monospace">AXP <- read.table(urls2[3], header=T, <a href="http://as.is" target="_blank">as.is</a>=T)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">sapply(c("AA", "AIG", "AXP"), function(x) length(get(x))) ### tamanhos diferentes</font></div><div><font face="monospace, monospace">sapply(c("AA", "AIG", "AXP"), function(x) tail(names(get(x))))</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">COR <- NULL</font></div><div><font face="monospace, monospace">for (i in 2:394) {</font></div><div><font face="monospace, monospace"> AA_AIG <- cor(AA[,i], AIG[,i], use = "pairwise.complete.obs")</font></div><div><font face="monospace, monospace"> AA_AXP <- cor(AA[,i], AXP[,i], use = "pairwise.complete.obs")</font></div><div><font face="monospace, monospace"> AIG_AXP <- cor(AIG[,i], AXP[,i], use = "pairwise.complete.obs")</font></div><div><font face="monospace, monospace"> row <- data.frame(i, AA_AIG, AA_AXP, AIG_AXP)</font></div><div><font face="monospace, monospace"> COR <- rbind(COR, row)</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">head(COR)</font></div></div><div><font face="monospace, monospace">### </code></font></div><div><br></div><div><br></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>Dourados, MS - [22 16.5'S, 54 49'W]<br></div></div></div>
<br><div class="gmail_quote">2015-03-18 13:38 GMT-04:00 Michelle Bau Graczyk <span dir="ltr"><<a href="mailto:mbgraczyk@gmail.com" target="_blank">mbgraczyk@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div>Boa tarde,<br><br></div>Eu tenho tres matrizes de tres empresas diferentes que estao dispostas da seguinte maneira:<br></div><div><br>Empresa AA <br></div>data 9:31<br>
<table cols="39" cellspacing="0" border="0" height="27" width="1556">
<colgroup width="37"></colgroup>
<colgroup width="77"></colgroup>
<colgroup span="3" width="55"></colgroup>
<colgroup width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup span="2" width="45"></colgroup>
<colgroup span="2" width="55"></colgroup>
<colgroup span="5" width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup span="2" width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup span="2" width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup width="45"></colgroup>
<colgroup span="6" width="55"></colgroup>
<colgroup span="4" width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup width="45"></colgroup>
<colgroup width="55"></colgroup>
<tbody><tr>
<td align="LEFT" height="16">data <br></td>
<td align="LEFT">09:31</td>
<td align="LEFT">09:32</td>
<td align="LEFT">09:33</td>
<td align="LEFT">09:34</td>
<td align="LEFT">09:35</td>
<td align="LEFT">09:36</td>
<td align="LEFT">09:37</td>
<td align="LEFT">09:38</td>
<td align="LEFT">09:39</td>
<td align="LEFT">09:40</td>
<td align="LEFT">09:41</td>
<td align="LEFT">09:42</td>
<td align="LEFT">09:43</td>
<td align="LEFT">09:44</td>
<td align="LEFT"> 09:45</td>
<td align="LEFT"> 09:46</td>
<td align="LEFT"> 09:47</td>
<td align="LEFT"> </td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
<td align="LEFT"><br></td>
</tr>
</tbody></table>
<br><div>
<table cols="23" cellspacing="0" border="0">
<colgroup width="77"></colgroup>
<colgroup span="3" width="55"></colgroup>
<colgroup width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup span="2" width="45"></colgroup>
<colgroup span="2" width="55"></colgroup>
<colgroup span="5" width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup span="2" width="45"></colgroup>
<colgroup width="55"></colgroup>
<colgroup span="2" width="45"></colgroup>
<tbody><tr>
<td align="LEFT" height="16"><br>2004-07-01</td>
<td align="RIGHT">700</td>
<td align="RIGHT">200</td>
<td align="RIGHT">7000</td>
<td align="RIGHT">9400</td>
<td align="RIGHT">1300</td>
<td align="RIGHT">1500</td>
<td align="RIGHT">6300</td>
<td align="RIGHT">1800</td>
<td align="RIGHT">4300</td>
<td align="RIGHT">1300</td>
<td align="RIGHT">4800</td>
<td align="RIGHT">3900</td>
<td align="RIGHT">2500</td>
<td align="RIGHT">4300</td>
<td align="RIGHT">4300</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-02</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="RIGHT">68900</td>
<td align="RIGHT">2800</td>
<td align="RIGHT">4900</td>
<td align="RIGHT">1200</td>
<td align="RIGHT">12300</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="RIGHT">6500</td>
<td align="LEFT">NA</td>
<td align="RIGHT">2900</td>
<td align="RIGHT">8900</td>
<td align="RIGHT">11600</td>
<td align="RIGHT">26900</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="LEFT"><br></td>
<td align="RIGHT"><br></td>
<td align="LEFT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-06</td>
<td align="RIGHT">800</td>
<td align="RIGHT">4400</td>
<td align="RIGHT">13700</td>
<td align="RIGHT">10700</td>
<td align="RIGHT">4700</td>
<td align="RIGHT">4000</td>
<td align="RIGHT">18700</td>
<td align="RIGHT">9000</td>
<td align="RIGHT">2100</td>
<td align="RIGHT">2300</td>
<td align="RIGHT">700</td>
<td align="RIGHT">8900</td>
<td align="RIGHT">10500</td>
<td align="RIGHT">3900</td>
<td align="RIGHT">8400</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-07</td>
<td align="LEFT">NA</td>
<td align="RIGHT">5600</td>
<td align="RIGHT">1000</td>
<td align="RIGHT">7300</td>
<td align="RIGHT">5600</td>
<td align="RIGHT">11200</td>
<td align="RIGHT">3900</td>
<td align="RIGHT">5800</td>
<td align="RIGHT">5700</td>
<td align="RIGHT">4500</td>
<td align="RIGHT">34400</td>
<td align="RIGHT">4100</td>
<td align="RIGHT">500</td>
<td align="RIGHT">15300</td>
<td align="RIGHT">500</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-08</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="RIGHT">154100</td>
<td align="RIGHT">42400</td>
<td align="RIGHT">16700</td>
<td align="RIGHT">4700</td>
<td align="RIGHT">5900</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-09</td>
<td align="LEFT">NA</td>
<td align="RIGHT">96900</td>
<td align="RIGHT">1000</td>
<td align="RIGHT">20400</td>
<td align="RIGHT">18300</td>
<td align="RIGHT">18000</td>
<td align="RIGHT">22500</td>
<td align="RIGHT">4100</td>
<td align="RIGHT">6000</td>
<td align="RIGHT">1000</td>
<td align="RIGHT">1900</td>
<td align="RIGHT">3700</td>
<td align="RIGHT">600</td>
<td align="RIGHT">2900</td>
<td align="RIGHT">14600</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-12</td>
<td align="RIGHT">1400</td>
<td align="RIGHT">100</td>
<td align="RIGHT">4500</td>
<td align="RIGHT">3000</td>
<td align="RIGHT">1300</td>
<td align="RIGHT">4200</td>
<td align="RIGHT">6500</td>
<td align="RIGHT">4500</td>
<td align="RIGHT">1600</td>
<td align="RIGHT">1600</td>
<td align="RIGHT">5600</td>
<td align="RIGHT">7600</td>
<td align="RIGHT">1900</td>
<td align="RIGHT">4600</td>
<td align="RIGHT">8300</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-13</td>
<td align="LEFT">NA</td>
<td align="RIGHT">5600</td>
<td align="RIGHT">3400</td>
<td align="RIGHT">16900</td>
<td align="RIGHT">9000</td>
<td align="RIGHT">5700</td>
<td align="RIGHT">16500</td>
<td align="RIGHT">1800</td>
<td align="RIGHT">21000</td>
<td align="RIGHT">6300</td>
<td align="RIGHT">5900</td>
<td align="RIGHT">12500</td>
<td align="RIGHT">51000</td>
<td align="RIGHT">7500</td>
<td align="RIGHT">13100</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-14</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="LEFT">NA</td>
<td align="RIGHT">164400</td>
<td align="RIGHT">35000</td>
<td align="RIGHT">41600</td>
<td align="RIGHT">56600</td>
<td align="RIGHT">27800</td>
<td align="RIGHT">36500</td>
<td align="RIGHT">55300</td>
<td align="RIGHT">29900</td>
<td align="RIGHT">13100</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-15</td>
<td align="LEFT">NA</td>
<td align="RIGHT">8100</td>
<td align="RIGHT">2000</td>
<td align="RIGHT">6100</td>
<td align="RIGHT">4900</td>
<td align="RIGHT">4500</td>
<td align="RIGHT">2500</td>
<td align="RIGHT">1400</td>
<td align="RIGHT">5200</td>
<td align="RIGHT">4100</td>
<td align="RIGHT">5400</td>
<td align="RIGHT">4000</td>
<td align="RIGHT">13400</td>
<td align="RIGHT">3200</td>
<td align="RIGHT">11300</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-16</td>
<td align="RIGHT">282300</td>
<td align="RIGHT">18100</td>
<td align="RIGHT">30400</td>
<td align="LEFT">NA</td>
<td align="RIGHT">15900</td>
<td align="RIGHT">40800</td>
<td align="RIGHT">9000</td>
<td align="RIGHT">5300</td>
<td align="RIGHT">5200</td>
<td align="RIGHT">27600</td>
<td align="RIGHT">7600</td>
<td align="RIGHT">12100</td>
<td align="RIGHT">8400</td>
<td align="RIGHT">1000</td>
<td align="RIGHT">8400</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
<tr>
<td align="LEFT" height="16">2004-07-19</td>
<td align="RIGHT">28700</td>
<td align="RIGHT">1700</td>
<td align="RIGHT">2900</td>
<td align="RIGHT">9500</td>
<td align="RIGHT">400</td>
<td align="RIGHT">2800</td>
<td align="RIGHT">1100</td>
<td align="RIGHT">6200</td>
<td align="RIGHT">11500</td>
<td align="RIGHT">17900</td>
<td align="RIGHT">11100</td>
<td align="RIGHT">16000</td>
<td align="RIGHT">6800</td>
<td align="RIGHT">5200</td>
<td align="RIGHT">7100</td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
<td align="RIGHT"><br></td>
</tr>
</tbody></table>
<br></div><div>Onde as datas vao de 2004-07-01 ate 2004-12-31(ao todo 128) e os horarios vao de 09:31 ate 16:04( ao todo 397)<br><br></div><div>Eu quero calcular a correlacao entre essas tres empresas para cada hora fixa,ou seja, para a empresa AA eu calculo com ela mesma e com a AIG e a AXP para cada hora fixa, e por isso montei este programa:<br><br>A<-read.table(file="/home/usuario/Documentos/AAparaCalculodaMedia.txt", header=TRUE)<br>AA.<-as.matrix(AA)<br>##write.table(AA.,"AA..txt")<br>AXP<-read.table("/home/usuario/Documentos/AXPparaCalculodaMedia.txt",header=TRUE)<br>AXP.<-as.matrix(AXP)<br>##write.table(AXP.,"AXP..txt")<br>AIG<-read.table("/home/usuario/Documentos/AIGparaCalculodaMedia.txt",header=TRUE)<br>AIG.<-as.matrix(AIG)<br><br>Symbols<-c("AA.","AIG.","AXP.")<br>matrizAA<-matrix()<br>j<-1<br>for (j in 1:length(Symbols)){<br> empresa<-paste0(Symbols)#,"[",j,"]")<br> <br> for (i in 2:397){<br> empresa1<-as.numeric(paste0(empresa,"[,",i,"]"))<br> head(empresa1)<br> matrizAA[,i-1]<-cor(as.numeric(AA.[,i]), as.numeric(empresa1), use="pairwise.complete.obs")<br> <br> }<br> <br>}<br><br></div><div>Mas da o erro: Erro em cor(as.numeric(AA.[, i]), as.numeric(empresa1), use = "pairwise.complete.obs") : <br> incompatible dimensions<br>Além disso: Mensagens de aviso perdidas:<br>NAs introduzidos por coerção<br><br></div><div>Eu achava que usando o use = "pairwise.complete.obs" as correlacoes seriam calculadas apenas entre pares de numeros, mas acho que isso nao esta acontecendo.<br></div><div>Os tres arquivos vou deixar em dropbox.<br><br></div><div>Muito obrigada,<br><br></div><div>Michelle<br></div></div>
<br></div></div>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div></div>
<br>_______________________________________________<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" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div>