[R] A simple For-Loop doesn't work

Nicolae Doban nickdoban at gmail.com
Sat Mar 14 18:28:28 CET 2015


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]]



More information about the R-help mailing list