Skip to content
Prev 275356 / 398503 Next

cycling through a long list of files and names

Thanks so much, this is very very helpful.

I do have one remaining question here. I definitely see the value of 
making a list of the datasets, an advise I will definitely follow. 
However, for educational purposes, I would still like to know how to 
automate the following without using a list:

city1997<- dataCleaning(read.csv2("C:\\city\\year1997.txt"))
city1997.waste<- wasteCalculations(city1997, year = 1997)
if (city1997.waste[1,1] == "Time") {city1997.time<- timeCalculations(city1997)}
city1998<- dataCleaning(read.csv2("C:\\city\\year1998.txt"))
city1998.waste<- wasteCalculations(city1998, year = 1998)
if (city1998.waste[1,1] == "Time") {city1998.time<- timeCalculations(city1998)}
city1999<- dataCleaning(read.csv2("C:\\city\\year1999.txt"))
city1999.waste<- wasteCalculations(city1999, year = 1999)
if (city1999.waste[1,1] == "Time") {city1999.time<- timeCalculations(city1999)}
save(city1997, city1998, city1999, city1997.waste, city1998.waste, city1999.waste, city1997.time, city1998.time, city1999.time, file = "cities.Rdata")

so, how do I create objects with appropriate names and then have 
functions applied to them. (this is only an example of the kinds of 
manipulations I need to do, but if I can get the above to work, then I 
can figure out the rest for myself).
Thanks for your help, can you solve this final piece of the puzzle as well?

--Peter



Op 23-10-2011 3:51, R. Michael Weylandt schreef: