我尝试了
make_tree()
的副本:
library(igraph)
myfun <-
function (n, children = 2, mode = c("out", "in", "undirected"))
{
mode <- igraph.match.arg(mode)
mode1 <- switch(mode, out = 0, `in` = 1, undirected = 2)
on.exit(.Call(R_igraph_finalizer))
res <- .Call(R_igraph_kary_tree, as.numeric(n), as.numeric(children),
as.numeric(mode1))
if (igraph_opt("add.params")) {
res$name <- "Tree"
res$children <- children
res$mode <- mode
}
res
}
myfun(n=3, children=2)
这给出:
Error in igraph.match.arg(mode) :
could not find function "igraph.match.arg"
igraph.match.arg()
和.Call()
在R库中可用?您需要告诉 R 从哪里获取不在搜索路径上的对象(例如,因为它们不是由包导出的)。
myfun <-
function (n, children = 2, mode = c("out", "in", "undirected"))
{
mode <- igraph:::igraph.match.arg(mode)
mode1 <- switch(mode, out = 0, `in` = 1, undirected = 2)
on.exit(.Call(igraph:::R_igraph_finalizer))
res <- .Call(igraph:::R_igraph_tree, as.numeric(n), as.numeric(children),
as.numeric(mode1))
if (igraph:::igraph_opt("add.params")) {
res$name <- "Tree"
res$children <- children
res$mode <- mode
}
res
}
myfun(n=3, children=2)
#works
R_igraph_kary_tree
不是来自 igraph 包。