Re: [R] variables with dynamic names?

From: Antje <niederlein-rstat_at_yahoo.de>
Date: Wed 25 Oct 2006 - 09:32:44 GMT

Thanks very much for your help.
I found the solution. I created a matrix with Strings and within a loop I read the files and processed them

wellInfo <- matrix(nrow = rows, ncol = cols) for(i in 1:rows) {

    tempRow <- paste(rowString[i], formatC(c(1:cols), flag="0", width=2), sep="")

    print(tempRow)
    wellInfo[i,] <- tempRow
}

for(i in 1:rows) {

    for(j in 1:cols) {

        filename <- paste(wellInfo[i,j],".csv",sep="")
        if( file.exists(filename)) {
            file <- read.csv(filename, sep="\t", header=F)
             ...
          }
      }

}

(It was quite simple, but I did not find the "paste" command before...) If there is something which could be done easier, just let me know.

Ciao,
Antje

Antje schrieb:
> Hello,
>
> I have the following problem. I have a set of CSV files and they are
> named for a special position in a matrix (e.g. "A01.csv", "F06.csv",
> "H11.csv")
>
> Now, I would like to read in the data of all these files and eveluate
> something for each set (and write it at the position in a result matrix).
> How can I realize this with R?
>
> Ciao,
> Antje
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
>



R-help@stat.math.ethz.ch 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. Received on Wed Oct 25 20:55:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 25 Oct 2006 - 19:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.