[R] assigning differences in a loop

Jean-Louis Abitbol abitbol at sent.com
Sun Feb 26 21:47:55 CET 2006


Dear All

I would need to generate differences between variates such as
nam1<-nam2-nam3 in the following loop:

for(i in c("13","26","38")) { 
    for (j in c("HR","PQ","QRS","QT")){
       nam1<-paste("d",j,i,sep="")
       nam2<-paste(j,i,sep=".")
       nam3<-paste(j,"0",sep=".")
       cat(nam1,"\n")
       cat(nam2,"\n")
       cat(nam3,"\n") 
      }}

for example the first difference would be dHR13<-HR.13-HR.0

I have tried

get(paste("d",j,i,sep=""))<-get(paste(j,i,sep="."))-get(paste(j,"0",sep="."))

which result in an error message such as "target of the assign does not
belong to the language" (translation from French).

I have looked in the FAQ but do not understand how to use assign in this
context.

Thanks for any help,

Kind regards, Jean-Louis
Dr. Jean-Louis Abitbol
Directeur Recherche Clinique
Trophos SA, Parc scientifique de Luminy, Case 931
Luminy Biotech Entreprises
13288 Marseille Cedex 9
Tel 04 91 82 82 73, Fax 04 91 82 82 89
Portable 06 24 47 59 34




More information about the R-help mailing list