[R] No visible binding for global variable

Naser Jamil jamilnaser79 at gmail.com
Fri Jan 27 16:43:55 CET 2017


Dear R-users,
I would like to seek your suggestion. I have the following code which runs
smoothly. But when I compile the function (lf1.c), it shows "no visible
binding for global variable" for some of the arguments.

###################################

library(compiler)


psi0<-function(theta1,theta2,theta3,theta4,x){
z1<-exp(theta1+theta2*x)
z2<-exp(theta3+theta4*x)
1/((1+z1)*(1+z2))
                                             }

psi1<-function(theta1,theta2,theta3,theta4,x){
z1<-exp(theta1+theta2*x)
z2<-exp(theta3+theta4*x)
z1/((1+z1)*(1+z2))
                                             }
psi2<-function(theta3,theta4,x) {
z2<-exp(theta3+theta4*x)
z2/(1+z2)
                                }



lf1<-function(w) {
   v<-1
   w1<-w[1]
   w2<-w[2]
   w3<-w[3]
   w4<-w[4]
   for (i in 1:length(alloc.dose)) {
       dose.i<-alloc.dose[i]
       r0.i<-r0[i]
       r1.i<-r1[i]
       r2.i<-r2[i]
       z1<-exp(w1+w2*dose.i)
       z2<-exp(w3+w4*dose.i)
       psi0<-1/((1+z1)*(1+z2))
       psi1<-z1*psi0
       v<-v*(psi0^r0.i)*(psi1^r1.i)*((1-psi0-psi1)^r2.i)
                                   }
   return(v)
                  }


lf1.c<-cmpfun(lf1)

###############################

May I know how to avoid this message? If I leave the code as it is, will
that affect the result anyway?

Thanks in advance.


Regards,
Jamil.

	[[alternative HTML version deleted]]



More information about the R-help mailing list