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. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.