Die class "ecdf" erbt von der Klasse "stepfun". Wenn f
eine solche empirische kumulative Dichtefunktion ist, sind sowohl is.stepfun(f)
als auch is(f,"stepfun")
TRUE
, und as.stepfun(f)
tut nichts wie erwartet. Aber Umwandlung von f
zu „stepfun“ von as(f,"stepfun")
ist wegen der „Metadaten“ unmöglich, auch wenn strict
ist FALSE
:R: Wie kommt es, dass "ist" WAHR ist, aber "wie" unmöglich ist?
f <- ecdf(1:10)
class(f)
# [1] "ecdf" "stepfun" "function"
is.stepfun(f)
# [1] TRUE
is(f,"stepfun")
# [1] TRUE
identical(f,as.stepfun(f))
# [1] TRUE
g <- as(f,"stepfun",strict=FALSE)
# Error in as(f, "stepfun", strict = FALSE) :
# internal problem in as(): “ecdf” is(object, "stepfun") is TRUE, but the metadata asserts that the 'is' relation is FALSE
Wie is
-as
verwandt ist und was ist die Bedeutung der „Metadaten“ Hier?
meinst du 'is.stepfun (f)' direkt nach 'class (f)'? –
Ich bin interessiert - wo haben Sie das Format "is (item, typedef)" im Gegensatz zum Format in allen Hilfeseiten "is.typedef (item)"? Sie können auch 'methods (as)' und ein paar ähnliche Untersuchungen ausprobieren, um zu sehen, was gerade mit der 'stepfun'-Klasse passiert. –
@Carl Witthoft: Die Suche nach "R coercing" führt zur [Dokumentation der 'as' Methode] (https://stat.ethz.ch/R-manual/R-devel/library/methods/html/as. html). Darin ist ein Link ([setIs] (https://stat.ethz.ch/R-manual/R-devel/library/methods/html/is.html)) zur [Dokumentation für die 'is' Methode] (https://stat.ethz.ch/R-manual/R-devel/library/methods/html/is.html). – mra68