[R] error in eval

peter dalgaard pdalgd at gmail.com
Tue Nov 26 15:00:52 CET 2013


AFAICT, your code should not be expected to run unless you have an attach(lizards) prior to the glm() call. Either that or you need data=lizards in the call itself.

-pd

On 26 Nov 2013, at 12:43 , philthe1st <philip.brown at bristol.ac.uk> wrote:

> Hi there, I am learning to use and understand R but have come up against a
> problem. I'm sure it is a pretty simple thing, but I can't find a solution.
> I wonder if anyone could help?
> 
> I have been using the "The R Book" by Crawley and working through some of
> the examples before trying to apply them to my data.
> 
> Yesterday I tried to following from page 560:
> 
>> lizards<-read.table('lizards.txt',header=T,sep='\t')
>> head(lizards)
>   n   sun height  perch    time  species
> 1 20 Shade   High  Broad Morning opalinus
> 2 13 Shade    Low  Broad Morning opalinus
> 3  8 Shade   High Narrow Morning opalinus
> 4  6 Shade    Low Narrow Morning opalinus
> 5 34   Sun   High  Broad Morning opalinus
> 6 31   Sun    Low  Broad Morning opalinus
>> model1<-glm(n~sun*height*perch*time*species,poisson)
> 
> The GLM worked and I got the correct results.
> 
> In the mean time I have had a play around with my data in R and installed
> package "pscl". I then then came to back to page 560 to play around with
> some variables and could not load the glm I needed. This time, using the
> exact same codes as above I received the message:
> 
> Error in eval(expr, envir, enclos) : object 'n' not found
> 
> Looking at other peoples questions about this problem I have tried changing
> "sep" but with no luck. Can anyone help  me work out what has changed since
> yesterday and how to get the glm codes working again?
> 
> Thank you in advance for any help/suggestions.
> Phil
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/error-in-eval-tp4681170.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list