转换自定义S4类的R方法

问题描述

我正在开发R包,并希望包含一个覆盖igraph::as.igraph()并允许用户将我的自定义类转换为igraph::igraph对象的函数。正确的方法是什么?

解决方法

从igraph包中导入泛型,然后为类导出方法。

#' @importFrom igraph as.igraph
NULL

#' @export
as.igraph.yourclass <- function(x,...)
{
    your code here
}