S4クラス(および参照クラス、さらに言えば、おそらく一部の人の悔しさ)は、S4クラスを使用して定義されます(クール(?)え?)
> class(trajclass)
[1] "classRepresentation"
attr(,"package")
[1] "methods"
> getClass(class(trajclass))
Class "classRepresentation" [package "methods"]
Slots:
Name: slots contains virtual prototype
Class: list list logical ANY
Name: validity access className package
Class: OptionalFunction list character character
Name: subclasses versionKey sealed
Class: list externalptr logical
Known Subclasses: "ClassUnionRepresentation", "refClassRepresentation"
私はあなたができる最善のことは
isS4(trajclass) && !is(trajclass, "classRepresentation")
S4は、 ;show
の同義語(一種)として使用します。print
そのためのS4show
メソッドclassRepresentation
があります
> selectMethod(show, class(traj))
Method Definition:
function (object)
{
cat(gettextf("Class generator function for class \"%s\" from package \"%s\"\n",
object@className, object@package))
show(as(object, "function"))
}
<bytecode: 0x1522d40>
<environment: 0xf1d808>
Signatures:
object
target "classGeneratorFunction"
defined "classGeneratorFunction"
一方、のshow
メソッドtrajobject
はデフォルトであり、
> selectMethod(show, class(trajobject))
Method Definition (Class "derivedDefaultMethod"):
function (object)
showDefault(object, FALSE)
<bytecode: 0x1516d08>
<environment: namespace:methods>
Signatures:
object
target "Trajectories"
defined "ANY"
で肉とmethods::showDefault
。私はあなたが実装できると思います
setGeneric("isNotS4ClassDef",
function(object) standardGeneric("isNotS4ClassDef"))
setMethod(isNotS4ClassDef, "ANY",
function(object) TRUE)
setMethod(isNotS4ClassDef, "classRepresentation",
function(object) FALSE)