Constant Error in R
On Oct 9, 2012, at 2:30 PM, bobo wrote:
Hi good R folks, I am hoping that you could help me resolve this issue. I tried finding answers online but to no avail. I keep getting this "Error in x^2 : non-numeric argument to binary operator" using multiple different codes, ones which have been verified to work by my professor and other students. I tried reinstalling R completely and it still didn't fix the issue. I am using the latest version and Mac 10.8.2. Thank you! I am posting the code where the error occurred below: library(foreign) library(lmtest) library(car) x.1 <- runif(1000,0,1) x.2 <- rbinom(1000,1,.5) b.1 <- 10 b.2 <- 2 mu <- 1+(x.1*b.1) + (x.2*b.2) Z <- cbind(x.1) gamma <- 10 sigma2 <- exp(2+Z*gamma) y <- mu +rnorm(1000) * sqrt(sigma2) lm.y<-lm(y~x.1+x.2) "Error in x^2 : non-numeric argument to binary operator"
Well, something is strange here. Your error message is stating that the interpreter was unable to find x^2, but you have no x^2 expression in your code. I ran the code (except for the library calls which were clearly not needed for those commands. No error. I then loaded the packages and re-ran the code. Again, no errors.
summary(lm.y)
You probably need to restart R with the --vanilla option or if you are using a GUI, locate and rename the .Rdata file and then restart. If the error persist, you should post sessionInfo() results.
David Winsemius, MD Alameda, CA, USA