Hi,
Your mistake is related with "read.table(n)". I haven`t got what you
want
but I put an example below (where I used loop to read many files). Hope it
helps. Anyway, I thougth should have sent your question to
<r-help@r-project.org>.
Bye
Nilza
=====example ===================nomesout <-
dir(dat.dir,pattern="^[s]") #obtem no diretorio de atual todos
arquivo iniciado com a letra s
OUT <- read.table(paste(dat.dir,nomesout[1] ,sep = ""),header =
FALSE, sep ",", na.strings =
c("/","///","////","/////","//////"))
for(i in 2:length(nomesout)){
Y <- read.table(paste(dat.dir,nomesout[i] ,sep = ""),header =
FALSE, sep ",")
OUT <- rbind(OUT, Y)
}
OUT <- OUT[-1,] ## Remove linhas em branco
On Fri, Dec 17, 2010 at 9:00 AM, <r-sig-db-request@r-project.org> wrote:
> Send R-sig-DB mailing list submissions to
> r-sig-db@r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
> or, via email, send a message with subject or body 'help' to
> r-sig-db-request@r-project.org
>
> You can reach the person managing the list at
> r-sig-db-owner@r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-DB digest..."
>
>
> Today's Topics:
>
> 1. Help with loop (Daniel)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 16 Dec 2010 21:47:47 -0200
> From: Daniel <dmsilv@gmail.com>
> To: r-sig-db@stat.math.ethz.ch
> Subject: [R-sig-DB] Help with loop
> Message-ID:
> <AANLkTik0GOA-KHUoFtqocj4uV-C81TLkcESgKDTf3=eq@mail.gmail.com>
> Content-Type: text/plain
>
> 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]]
>
>
>
> ------------------------------
>
> _______________________________________________
> R-sig-DB mailing list
> R-sig-DB@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>
>
> End of R-sig-DB Digest, Vol 74, Issue 2
> ***************************************
>
--
Abraço,
Nilza Barros
[[alternative HTML version deleted]]