[R] assigning differences in a loop

From: Jean-Louis Abitbol <abitbol_at_sent.com>
Date: Mon 27 Feb 2006 - 07:47:55 EST


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



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 Mon Feb 27 07:59:55 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:45 EST