[R] variable-substitution / command-substitution

Damaris Zurell damaris at zurell.de
Tue Apr 11 09:45:25 CEST 2006


Hello,

I have about 2000 data files which I want to analyse.
The file names are all very similar => 
p"variable1"_t"variable2"_c"variable3".txt
There aren´t so much different variables (about 70) , just different 
combinations of them.
To allow an easy way of handling those data files I was wondering 
whether R is able to do variable-substitution /command-substitution 
similar to shell-programming, so that I could imbed the read.table 
option (and further commands) in 3 loops (one for every variable in the 
filenames) .

e.g.:
for var1 in (varlist1)
 for var2 in (varlist2)
  for var3 in (varlist3)
   read.table("..../p$var1_t$var2_c$var3.txt")
   ....statistics......
  done
 done
done


Cheers,
Damaris




More information about the R-help mailing list