Pay attention to the i counter in the loop: it runs from 1 to 6 but data has only 3 elements Il 15/mar/2015 04:56 "Nicolae Doban" <nickdo...@gmail.com> ha scritto:
> Hello, > > my name is Nick and I'm working on a project. I'm having trouble with > building a simple for-loop. In this loop I want to read csv files, perform > a corr function and save it to a pdf file. I tried to solve this problem by > looking for solutions online but couldn't figure it out. Could you also > tell me if if it is possible to name the dataframe(grid.table())?Could you > please help me? > > The code I wrote and which doesn't work is: > * <Code>* > Data <- c("July", "August", "September") > > pdf("Cor.pdf") > setwd("path") > for(i in 1:6){ > > Data[i] <- read.csv(Data[i],".csv", header=T) > > grid.table(cor(Data[i][3:10])) > corrgram(Data[i], order=TRUE, lower.panel=panel.shade, > upper.panel=panel.pie, text.panel=panel.txt, > main=Data[i],"Cor") > > } > dev.off() > * </Code>* > > Thank you, > Nick > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.