[R] R beginner - Error in as.vector(x, mode)

Alex Olssen alex.olssen at gmail.com
Thu Mar 10 09:46:53 CET 2011


Hi everyone,

I am new to R and keep getting the message
Error in as.vector(x, mode)
while trying to run nlsystemfit.

Below is my exact code.  The data is in Stata format because I only
recently swapped to R and am trying to compare results from Stata to
make sure I know what is going on.
I have searched google and read sever R-help articles with this error.
 They all say the problem is to do with attach().  I haven't used
attach() as far as I can tell.  However it does seem to be a problem
with reading the data.  I sometimes get a problem with "masking".
Finally, when I ran the example in the systemfit documentation for
nlsystemfit everything went fine.  The major structural difference I
can see between the codes is they use data() where as I do not.

Any advice would be truly appreciated.

library(systemfit)
library(foreign)
auto74 <- read.dta("auto74.dta")
eqWeight <- weight ~ a0 + a1*mpg + a2*price + a3*trunk
eqLength <- length ~ b0 + b1*mpg + b2*price + b3*trunk
model <- list(eqWeight, eqLength)
start.values <- c(a0=0, a1=0, a2=0, a3=0, b0=0, b1=0, b2=0, b3=0)
nlsystemfit("OLS", model, start.values, data = auto)

Error in as.vector(x, mode) :
  cannot coerce type 'builtin' to vector of type 'any'

Kind regards,

Alex Olssen



More information about the R-help mailing list