[R] error message in eval

Rolf Turner r.turner at auckland.ac.nz
Thu Sep 27 03:10:33 CEST 2007


On 27/09/2007, at 12:27 PM, ckang2 at gmail.com wrote:

> Hello, Listers
>
> I'm trying to run blloean logit model with R.
>
> My code is:
>
>> library(boolean)
>> library(foreign)
>> pr <- read.dta ("prcore1.dta")
>> bp <- boolprep ("(a&b)|c", "cwt", a="O1", b="t", c="DM2
>> + ah + md + con + n3 + rel + slo + pyrs
>> + sp1 + sp2 + spl3")
>> answer <- boolean (bp, link = "logit", method = "nlm")
>
> But I got an error message here as follows:
>
> Error in eval(expr, envir, enclos) : object "cwt" not found
>
> "cwt" is my D.V. and I made sure that R read the data correctly.
>
> It might be a stupid question.But, since I'm a very very beginner of
> R, I don't know what's wrong.
> I tried to figure out this with the manual, but I can't get any  
> answer.
>
> Could you anyone help me out?

The variable ``cwt'' is a component of the data frame ``pr''; it is  
not lying
around loose in the workspace (global environment) where the function  
boolean()
can see it.  You need to tell boolean() where to find ``cwt'' and the  
other variables
referred to.  I don't know from the boolean package, but I conjecture  
that the
boolean function has a ``data'' argument, in which case

	answer <- boolean (bp, link = "logit", method = "nlm",data=pr)

may work.  Otherwise you could

	(a) do:

			attach(pr)

	prior to the call to boolean, or

	(b) use with():

	answer <- with(pr, boolean (bp, link = "logit", method = "nlm"))

			cheers,

				Rolf Turner



######################################################################
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}



More information about the R-help mailing list