Frage

I want to use functions from the Bioconductor packages hypergraph and hyperdraw without loading the packages. When running an example from the hyperdraw vignette

dh1 <- hypergraph::DirectedHyperedge("A", "B", "R1")
dh2 <- hypergraph::DirectedHyperedge(c("A", "B"), c("C", "D"), "R2")
hg <- hypergraph::Hypergraph(LETTERS[1:5], list(dh1, dh2))
hgbph <- hyperdraw::graphBPH(hg)

I get the error:

Error in hyperdraw::graphBPH(hg) : could not find function "hyperedges"

If I try to load hyperedges:

hyperedges <- hyperdraw:::hyperedges

I get the error

Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'hyperedges' not found

When I load both packages using library or require, I get no error (in running the above code without hypergraph:: and hyperdraw::).

The reason why I do not want to load the packages is because I am building a package which uses hyperdraw and hypergraph in only one function and I'd rather put these packages into Suggests than into Depends in my DESCRPTION file.

Does anyone have an idea how to solve this?

War es hilfreich?

Lösung

hyperdraw has this in it's DESCRIPTION file

Depends:      R (>= 2.9.0), methods, grid, graph, hypergraph, Rgraphviz

and it's relying on finding hypergraph::hyperedges on the search() path. Personally, I think hyperdraw should include a line

importFrom(hypergraph, hyperedges)

in it's NAMESPACE file. Currently, the best thing to do is to add Depends: hyperdraw to your DESCRIPTION file, and to importFrom(hyperdraw, <whatever functions you need>). I have contacted the maintainer of hyperdraw to ask them to update the NAMESPACE as above; you could then merely Imports: hyperdraw. I think you're just making work for yourself and frustrating your users by trying to use Suggests or other approaches to subvert the need for formal dependencies.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top