Skip to content

Loading survMisc removes the default methods of xtable #17

@nicholashanoian

Description

@nicholashanoian

Hello,

Loading xtable and then survMisc removes all of xtable's default methods.
You can see that the methods are being removed by running methods(xtable) before and after loading survMisc. I am using R version 3.5.3, survMisc 0.5.5 , and xtable 1.8-3.

See the following example:

library(xtable)

# make a data frame and print an xtable of it, works fine
df <- data.frame(x=1:5, y=2:6)
xtable(df) 
#> % latex table generated in R 3.5.3 by xtable 1.8-3 package
#> % Sat Apr 27 00:29:08 2019
#> \begin{table}[ht]
#> \centering
#> \begin{tabular}{rrr}
#>   \hline
#>  & x & y \\ 
#>   \hline
#> 1 &   1 &   2 \\ 
#>   2 &   2 &   3 \\ 
#>   3 &   3 &   4 \\ 
#>   4 &   4 &   5 \\ 
#>   5 &   5 &   6 \\ 
#>    \hline
#> \end{tabular}
#> \end{table}

# show the methods of xtable
methods(xtable) 
#>  [1] xtable.anova*            xtable.aov*             
#>  [3] xtable.aovlist*          xtable.coxph*           
#>  [5] xtable.data.frame*       xtable.glm*             
#>  [7] xtable.gmsar*            xtable.lagImpact*       
#>  [9] xtable.lm*               xtable.matrix*          
#> [11] xtable.prcomp*           xtable.sarlm*           
#> [13] xtable.sarlm.pred*       xtable.spautolm*        
#> [15] xtable.sphet*            xtable.splm*            
#> [17] xtable.stsls*            xtable.summary.aov*     
#> [19] xtable.summary.aovlist*  xtable.summary.glm*     
#> [21] xtable.summary.gmsar*    xtable.summary.lm*      
#> [23] xtable.summary.prcomp*   xtable.summary.sarlm*   
#> [25] xtable.summary.spautolm* xtable.summary.sphet*   
#> [27] xtable.summary.splm*     xtable.summary.stsls*   
#> [29] xtable.table*            xtable.ts*              
#> [31] xtable.zoo*             
#> see '?methods' for accessing help and source code


# now load survMisc, it warns about masking xtable
library(survMisc) 
#> Loading required package: survival
#> 
#> Attaching package: 'survMisc'
#> The following object is masked from 'package:xtable':
#> 
#>     xtable

# try to print the xtable again
xtable(df)
#> Error in UseMethod("xtable"): no applicable method for 'xtable' applied to an object of class "data.frame"

# show the methods of xtable now
methods(xtable) # just xtable.survfit* and xtable.table*  
#> [1] xtable.survfit* xtable.table*  
#> see '?methods' for accessing help and source code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions