Oi Éder, usando o get deu certo!!!! Muito obrigada!
E o programa também que você montou, muito obrigada! Assim eu começo a aperfeiçoar a lógica do R. Mais uma vez muito obrigada! Em 19 de março de 2015 15:40, Éder Comunello <[email protected]> escreveu: > Michelle, > > Aproveitando seu código inicial, pensei em algo assim... > > ### <code r> > urls1 <- c(" > https://www.dropbox.com/s/kgxo3s8qrrv74p3/AAparaCalculodaMedia.txt", > " > https://www.dropbox.com/s/fhutciprhgt077x/AIGparaCalculodaMedia.txt", > " > https://www.dropbox.com/s/kvubgji1tce8sm8/AXPparaCalculodaMedia.txt") > > urls2 <- sub("^.*/s/", "http://dl.dropbox.com/s/", urls1) > > AA <- read.table(urls2[1], header=T, as.is=T) > AIG <- read.table(urls2[2], header=T, as.is=T) > AXP <- read.table(urls2[3], header=T, as.is=T) > > Symbols <- c("AA", "AIG", "AXP") > sapply(Symbols, function(x) length(get(x))) > sapply(Symbols, function(x) nrow(get(x))) > sapply(Symbols, function(x) tail(names(get(x)),1)) > > ### Correlações entre leituras diferentes da mesma empresa > cor(AA[2:394], use="pairwise.complete.obs") > cor(AIG[2:394], use="pairwise.complete.obs") > cor(AXP[2:394], use="pairwise.complete.obs") > > ### Correlações entre mesma leitura das diferentes empresas > ### Testando com 4 matrizes > Symbols <- c("AA", "AIG", "AXP", "AXP") > > COR <- NULL > for (i in 2:394) { > DAT <- NULL > for (a in Symbols) { > col <- get(a)[,i] > DAT <- cbind(DAT, col) > } > lin <- cbind(ID=i, cor(DAT, use="pairwise.complete.obs")) > colnames(lin) <- c("ID", Symbols) > COR <- rbind(COR, lin) > } > > ### As 4 matrizes originariam uma matriz cor 4x4 para cada leitura > ### As matrizes cor foram empilhadas em uma saída única (COR), onde > ### cada 4 linhas são referentes à uma leitura identificada por ID. > > head(COR) > # ID AA AIG AXP AXP > # col 2 1.00000000 0.64408120 -0.088884203 -0.088884203 > # col 2 0.64408120 1.00000000 -0.109883913 -0.109883913 > # col 2 -0.08888420 -0.10988391 1.000000000 1.000000000 > # col 2 -0.08888420 -0.10988391 1.000000000 1.000000000 > # col 3 1.00000000 0.01779314 0.003447422 0.003447422 > # col 3 0.01779314 1.00000000 0.158657131 0.158657131 > ### </code> > > > Éder Comunello <c <[email protected]>[email protected]> > Dourados, MS - [22 16.5'S, 54 49'W] > > > > _______________________________________________ > R-br mailing list > [email protected] > https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br > Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça > código mínimo reproduzível. >
_______________________________________________ R-br mailing list [email protected] https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.
