Dirk Koschuetzki
2005-Mar-15 18:20 UTC
[R] How do I call a masked function in a package without a namespace?
Hello, I work with two packages sna and graph from CRAN resp. Bioconductor. Both packages have a function called "degree". Therefore one of the functions is masked by the other and which one gets called depends on the order of loading. The problem is that both package do not have a namespace, therefore calling the masked function with "package::degree" does not work. See the following transcript: $ R --vanilla [[ Running on Debian Sarge ]] R : Copyright 2004, The R Foundation for Statistical Computing Version 2.0.1 (2004-11-15), ISBN 3-900051-07-0 [...]> library("sna") > library("graph")Loading required package: cluster Loading required package: Ruuid Creating a new generic function for "print" in "Ruuid" Loading required package: Biobase Loading required package: tools Welcome to Bioconductor Vignettes contain introductory material. To view, simply type: openVignette() For details on reading vignettes, see the openVignette help page.> conflicts()[1] "last.warning" "degree" "body<-" "print" "split" [6] "union"> sna::degree()Error in loadNamespace(name) : package 'sna' does not have a name space> graph::degree()Error in loadNamespace(name) : package 'graph' does not have a name space> sna:::degreeError in loadNamespace(name) : package 'sna' does not have a name space> graph:::degreeError in loadNamespace(name) : package 'graph' does not have a name space Is there a way to call the masked function via a different way? And I wold like to create my own function degree which will of course masked both functions and should therefore be able to call both functions. Thanks for any hint! Cheers, Dirk
Gabor Grothendieck
2005-Mar-15 20:27 UTC
[R] How do I call a masked function in a package without a namespace?
Dirk Koschuetzki <dkoschuetzki <at> gmx.de> writes: : : Hello, : : I work with two packages sna and graph from CRAN resp. Bioconductor. Both : packages have a function called "degree". Therefore one of the functions : is masked by the other and which one gets called depends on the order of : loading. The problem is that both package do not have a namespace, : therefore calling the masked function with "package::degree" does not : work. See the following transcript: : : $ R --vanilla : : [[ Running on Debian Sarge ]] : : R : Copyright 2004, The R Foundation for Statistical Computing : Version 2.0.1 (2004-11-15), ISBN 3-900051-07-0 : [...] : : > library("sna") : > library("graph") : Loading required package: cluster : Loading required package: Ruuid : Creating a new generic function for "print" in "Ruuid" : Loading required package: Biobase : Loading required package: tools : Welcome to Bioconductor : Vignettes contain introductory material. To view, : simply type: openVignette() : For details on reading vignettes, see : the openVignette help page. : > conflicts() : [1] "last.warning" "degree" "body<-" "print" "split" : [6] "union" : : > sna::degree() : Error in loadNamespace(name) : package 'sna' does not have a name space : > graph::degree() : Error in loadNamespace(name) : package 'graph' does not have a name space : > sna:::degree : Error in loadNamespace(name) : package 'sna' does not have a name space : > graph:::degree : Error in loadNamespace(name) : package 'graph' does not have a name space : : Is there a way to call the masked function via a different way? : And I wold like to create my own function degree which will of course : masked both functions and should therefore be able to call both functions. : The following looks up the position of the graph package on the search path and gets degree specifically from there, invokes it with the indicates arguments. graph.degree <- function(...) get("degree", grep("package:graph$", search()))(...)
Possibly Parallel Threads
- How do I call a masked function in a package without a na mespace?
- [BioC] problem loading affycoretools (more details)
- Error loading a dependency in a package: missing namespace?
- Error in opening .RData containing a genefilter object
- Error: package/namespace load failed for 'IlluminaHumanMethylation27k.db'