Skip to content
Prev 303164 / 398503 Next

What's wrong with my code?

stephenxqy wrote
1. What language is this? # starts a comment line in R not %%.
2. no data for q
3. what is I in Pfit?
4. Pexv: missing * or + or ... The expression in the function Pexv should
probably read

   
w(q*Rg(L,b))*PDebye(L,b)+(1-w(q*Rg(L,b)))*(1.22*(q*Rg(L,b))^(-1/v)+0.4288*(q*Rg(L,b))^(-2/v)-1.651*(q*Rg(L,b))^(-1/v)) 

I have inserted  * after    (1-w(q*Rg(L,b))) assuming that is what you want.

Your code is not reproducible since you have not provided data for q or I.
Generating some random data and assuming I is an identity matrix with 

set.seed(123)
q <- rnorm(20) + 5 
I <- diag(length(q))

adding wavefit at the end of the script and changing the %% to # your script
runs with no errors but with warnings.
So I can't tell you why you  get the error message you got.

Finally: this is very inefficient code. There are repeated evaluations of
same thing e.g. w(q*Rg(L,b)), Rg(L,b), Rg0sq(L,b) etc.

Berend





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