我想使用nrow函数来为我定义的类稍微不同。但我也不想掩盖nrow功能,所以我想重新定义nrow作为R - 使用基函数创建泛型
nrow <- function(x) UseMethod("nrow")
nrow.matrix <- function(x) base::nrow(x)
nrow.data.frame <- function(x) base::nrow(x)
nrow.list <- function(x) base::nrow(x) # should return NULL
nrow.numeric <- function(x) base::nrow(x) # should return NULL
nrow.character <- function(x) base::nrow(x) # should return NULL
nrow.ts <- function(x) base::nrow(x) # should return NULL
是这种东西,犹太?这是做错了吗?
没有尝试过,但也许,如果你给一个“模糊”的属性上您的课功能'nrow'将工作和返回'暗淡(X)[1]'? – flodel 2014-10-26 14:12:09
'nrow'不是原始的。 – Roland 2014-10-26 14:12:35
你是,将编辑。 – csta 2014-10-26 14:13:50