Skip to content
Prev 140667 / 398506 Next

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

I've been trying to dynamically detach and attach things in my Sweave,  
in order to circumvent the problem.

Here is my first attempt:
pkg <- 'package:AlgDesign'
p <- is.na(match(pkg, search()))
ifelse(p  == FALSE, detach(pkg), NA)
require(alr3)

My first two runs show that I've done something wrong:

 > Sweave('20080331.Rnw')
Writing to file 20080331.tex
Processing code chunks ...
  1 : term hide (label=setup)
  2 : echo term verbatim (label=oatvar)
  3 : echo term verbatim (label=oatvar1)
  4 : echo term verbatim (label=oat2wt)
  5 : echo term verbatim (label=oat2wt)
  6 : echo term verbatim (label=lm)
  7 : echo term verbatim (label=diag)
  8 : echo term verbatim (label=tukey)
  9 : echo term verbatim (label=nonad)
10 : echo term verbatim (label=efficiency)
11 : echo term verbatim (label=wear)
12 : echo term verbatim (label=wearX)
13 : echo term verbatim (label=gyd)
Loading required package: crossdes
Loading required package: AlgDesign
14 : echo term verbatim (label=2wt)
15 : echo term verbatim (label=ablm)
16 : echo term verbatim (label=abaov)
17 : echo term verbatim (label=abTukey)
18 : echo term verbatim (label=effAb)
19 : echo term verbatim (label=rabbit)
20 : echo term verbatim (label=rabbit2)
21 : echo term verbatim (label=rabbit2wt)

You can now run LaTeX on '20080331.tex'
There were 42 warnings (use warnings() to see them)
 > Sweave('20080331.Rnw')
Writing to file 20080331.tex
Processing code chunks ...
  1 : term hide (label=setup)
  2 : echo term verbatim (label=oatvar)
  3 : echo term verbatim (label=oatvar1)
  4 : echo term verbatim (label=oat2wt)
  5 : echo term verbatim (label=oat2wt)
  6 : echo term verbatim (label=lm)
  7 : echo term verbatim (label=diag)
  8 : echo term verbatim (label=tukey)

Error:  chunk 8 (label=tukey)
Error in detach(pkg) : invalid name
 > pkg
[1] "package:AlgDesign"

(1) I should learn how to fix the above code.

(2) In general, in preparing scripts, perhaps one should just ditch  
all the loaded packages at the beginning of each run, so as to insure  
that users won't get bitten by packages I had loaded but didn't do so  
explicitly in the Sweave script, *and* it would solve the current  
problem as well. Is there a straightforward way to do that?
On Mar 30, 2008, at 9:43 AM, Duncan Murdoch wrote:

            
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766
WWW:    http://www.people.virginia.edu/~mk9y/