Dear R helpers
 
Some particular analysis leads me to various number of output csv files 
depending on some conditions. Say e.g. I have output files variable1.csv, 
variable2.csv, .............. Problem is I don't know how many csv files been 
generated. They could be 4, 5 or even 10. Each file will have a column called 
amount.
 
My problem is to find filewise mean(amount) and sd(amount). I need to write a 
loop where all these individual csv files will be read and after reading each 
file, mean and sd will be calculated.
 
I have tried to write some R code which is very absurd. 
 
for (i in 1 : n)  # n is no of input files
 
{
data[i] = read.csv(file = paste("variable", i, ".csv", sep = ""))$amount
mean(data[i])
sd(data[i])
}
 
I get following error.
 
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'paste("output", i, ".csv", sep = "")': Invalid argument

 
Please guide
 
Regards
 
Madhavi


      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to