• R语言
  • 实现dist作为S4对象的一个slot的数据类型

setClass("tst",representation(mat="matrix", Distmat="dist"))

Build的时候警告:

Warning: undefined slot classes in definition of "tst": Distmat(class "dist")

感觉应该先继承dist类,如何实现?谢谢。
[未知用户]
setOldClass("dist")
setClass("tst",representation(mat="matrix", Distmat="dist"))
多谢。
不过cos的活跃度的确没有so高啊。
ref: http://stackoverflow.com/questions/27565535/how-to-make-a-class-of-slot-for-a-s4-class-as-dist
又有新问题哈。document()时报错了:
Error: Failure in roxygen block beginning tst-class.R:27
Missing name

27为setOldClass("dist")
代码大致(slot部分有删除)如下:
#' An S4 class.
#'
#' @slot mat Either a numeric matrix.
#' @slot Distmat the distance matrix.
#' @exportClass tst

setOldClass("dist")

setClass("tst", slots= list(mat="matrix",
                          Distmat="dist"))
问题应该是这里有两个Class。