Skip to content
Prev 140679 / 398506 Next

Clash between alr3 and AlgDesign. (Was: Re: Second & subsequent calls to function fails. Please help debug.)

On 30/03/2008 10:06 AM, Michael Kubovy wrote:
You can't use detach this way.  It is fine to say 
detach("package:AlgDesign") or detach(AlgDesign), but the way detach is 
written, you're attempting to detach something named "pkg".

This rewrite of your code is untested, but I think it should work:

pkg <- 'package:AlgDesign'
p <- match(pkg, search())
if (!is.na(p)) detach(pos=p)
require(alr3)

I've also changed your ifelse() to if (), and not just because I don't 
need an else clause:  ifelse() is designed to do computations on 
vectors, if() is designed for flow control.  I think we want flow 
control here.

Duncan Murdoch