[R] Help with looping

Alexandra Catena amc5981 at gmail.com
Tue Feb 17 19:15:01 CET 2015


Hi,

I need help with a for loop and printing data.  I want to loop through a
few years and print the data from each year stacked on top of each other.
For example,

for (i in 2000:2003){
#script for downloading each year
Data = readLines(sprintf('file/%4i,i))
}

It only prints out the data from the last year.  Also, I tried

Data[i] =  readLines(sprintf('file/%4i,i))

but it says:

"number of items to replace is not a multiple of replacement length"

How do I get it to not replace each year of data? I have R version 2.15.1

Thanks,
Alexandra

	[[alternative HTML version deleted]]



More information about the R-help mailing list