Re: [R] evaluating string variables

From: Berton Gunter <gunter.berton_at_gene.com>
Date: Sat 13 Aug 2005 - 01:03:29 EST

Given my own language inadequacies (I speak only one), I must, of necessity, refrain from criticizing the multilingual. However, in this one instance my sensibilities have been overwhelmed: "symmetric" , please :-) .

Incidentally, you may find that file.path() is also useful.

Cheers,
Bert

"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box    

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of
> Leonardo Sepulveda Durán
> Sent: Friday, August 12, 2005 7:44 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] evaluating string variables
>
> Hello!!!
>
> I have a folder (C:/R/) with matrix files, named by number, i.e.
> 0.mat, 1.mat,...,1250.mat. In this case, they are 5x5 simetric
> matrices. I would like to compute a property for each matrix and put
> calculated values into a data frame for posterior ploting and
> printing. Below there is an example for 7 matrices (0.mat..6.mat)
>
> #define data frame
> L <- data.frame(frame=numeric(7), L=numeric(7))
> f0<-1/(5*(5-1)) # first variable for computation
>
> #loop over matrices, Open it , calculate property and put
> into data frame
> for(i in 0:6){
> m<-matrix(scan('C:/R/i.mat', n=5*5),5,5, byrow=TRUE) #
> load matrix
> f1<-geodist(m)
>
> f2<-sum(colSums(f1$gdist))
>
> l <-f0*f2
>
> # Calculate property
> L[i+1, ]<-c(i,l)
>
> # Fill data frame
> }
>
> but the matrix cannot be loaded, because it try to open a file named
> "i.mat". I don`t know how to loop with a counter named 'i', and use it
> to define the name of the file too. How can i do it? I have not found
> the way.
>
> Leonardo
>
> ______________________________________________
> 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
>



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 Received on Sat Aug 13 01:09:40 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:16:57 EST