[R] Package manual examples - 'unexpected$undefined' errors

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jul 30 16:35:49 CEST 2007

David Pain wrote:
> Trying out an unfamiliar package, the natural thing is to use the examples
> given in the package's manual - hopefully, the writers of the package
> wouldn't include examples which didn't work!
> Recently, though, I've been getting 'unexpected$undefined' error messages
> when doing this, despite having copy/pasted the text from the manual (taking
> out hard breaks on the way).
> Moreover, I've had error messages for commands which I've previously had
> work fine.
> For instance, this from Zelig
> z.out <­ zelig(vote ~ race + educate, model = "logit", data = turnout)
> has at different times worked fine and thrown up the error message.
> Any help gratefully received.
> 	[[alternative HTML version deleted]]
It's hard to say exactly what's going wrong, but a guess is that in your 
workspace you have an object which is somehow conflicting with an object 
in the package.  Try starting R with the --vanilla command line option
and if the errors go away, that's why.

I don't know whether this applies to the Zelig package, but packages 
that don't define namespaces are fragile in that their internal 
functions can be masked by same-named functions in your workspace.  Even 
if the package does have a namespace, you can mask functions from it 
that you call:  for example, if you had a function called zelig (perhaps 
because you used fix(zelig) to make a small change to the existing one), 
your line above would call yours, not the original.

Duncan Murdoch

More information about the R-help mailing list