[R-sig-DB] Help with loop

Daniel dm@||v @end|ng |rom gm@||@com
Fri Dec 17 00:47:47 CET 2010


Hello all,
Is there a way to get each file from a website list and aggregate in a
unique file?
Otherwise I have to type 23 thousand web address into a long script like it:

base1 <- read.table("site 1", sep=";", header=T,
fileEncoding="windows-1252")
base2 <- read.table("site 2", sep=";", header=T,
fileEncoding="windows-1252")

I need to download each .CSV file from each web address and "rbind" all them
into one data frame.
Also I need to translate each object to UTF-8. Of course many of address
maybe be empty, so, my loop can't stops because this.

I never type a loop before, so, in my first shot I get an error. Can
somebody help me?

myresult <- NULL
n <-length(mysites)
for (i in 1:n) {
 bases <- read.table(n)
 bases[i]<-read.table(mysites[[i]], sep=";", header=TRUE,
fileEncoding="windows-1252")
tudo <- rbind(myresult, bases)
}

Error in read.table(n) : 'file' must be a character string or connection
-- 
Daniel Marcelino
Skype: dmsilv
www.sites.google.com/site/politicaevoce/ <http://bit.ly/pol4vc>

	[[alternative HTML version deleted]]




More information about the R-sig-DB mailing list