[R] What's wrong with my code?

Berend Hasselman bhh at xs4all.nl
Sun Aug 12 16:42:12 CEST 2012


stephenxqy wrote
> 
> Yes, missing * is the problem. Thank you a lot. Do you mean I need to
> incorporate all expression of Rg0sq, Rg etc. into the final Pfit function?
> 

Not necessarily. For example in function Pexv you evaluate Rg(L,b) 5 times.
You can also do this evaluating Rg(L,b) once and the same thing for the
evaluation of w(...)

Pexv<-function(v,L,b) {
    RgLb <- Rg(L,b)
    wq <- w(q*RgLb) 
   
wq*PDebye(L,b)+(1-wq)*(1.22*(q*RgLb)^(-1/v)+0.4288*(q*RgLb)^(-2/v)-1.651*(q*RgLb)^(-1/v)) 
}

Other functions can be treated in a similar way.
Depending on how often Pfit is called and/or how long the vector q is, this
could save you some cpu time.

Berend





--
View this message in context: http://r.789695.n4.nabble.com/What-s-wrong-with-my-code-tp4640034p4640093.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list