Skip to content
Prev 69791 / 398525 Next

Conflict between xtable and Hmisc when using Sweave?

Hi Andy and Gabor,

Thanks for your help so far! I am discovering another R dimension.

Trying to put my head around all this....the conflict actually exposes 
itself when calling summarize(Hmisc). Summarize(Hmisc) calls label 
internally, so I can not call it explicitly. Simply calling 
label(xtable) explicitly will not solve the problem with summarize(Hmisc).

Thus, I should use namespaces as Andy is suggesting. Now I just need to 
know how I 'add namespace' to a library? Does 'loadNamespace' have 
something to do with it?

Thanks very much for your help!

Sander.


## From Venables and Ripley (2002) p.165.
N <- c(0,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0)
P <- c(1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0)
K <- c(1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0)
yield <-c(49.5,62.8,46.8,57.0,59.8,58.5,55.5,56.0,
       62.8,55.8,69.5,55.0,
       62.0,48.8,45.5,44.2,52.0,
       51.5,49.8,48.8,57.2,59.0,53.2,56.0)
npk <- data.frame(block=gl(6,4), N=factor(N), P=factor(P),
                   K=factor(K), yield=yield)
## to show the effects of re-ordering terms contrast the two fits
tmpAov <- aov(yield ~ block + N * P + K, npk)
tmpTable <- xtable(tmpAov , caption="Test export of ANOVA table.",
   label="tab:Anova")
print.xtable(tmpTable, type="latex", floating=TRUE,
   table.placement="h", caption.placement="top",
   latex.environments=c("center"))

Alternatively, using namespace for xtable:

tmpTable <- xtable(tmpAov , caption="Test export of ANOVA table.")
xtable:::label(tmpTable) <- paste("tab:Anova")
print.xtable(tmpTable, type="latex", floating=TRUE,
   table.placement="ht", caption.placement="top",
   latex.environments=c("center"))
Gabor Grothendieck wrote: