Obiekt class "ecdf" dziedziczy po klasie "stepfun". Jeśli f
jest taką empiryczną skumulowaną funkcją gęstości, zarówno is.stepfun(f)
, jak i is(f,"stepfun")
są TRUE
, a as.stepfun(f)
nie robi niczego zgodnie z oczekiwaniami. Ale konwersja f
do „stepfun” przez as(f,"stepfun")
jest niemożliwe ze względu na „metadane”, nawet jeśli strict
jest FALSE
:R: Dlaczego to "jest" jest PRAWDĄ, ale "jak" jest niemożliwe?
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
Więc jak jest is
związane as
i jaki jest sens „metadane” tutaj?
miałeś na myśli 'is.stepfun (f)' zaraz po 'class (f)'? –
Jestem zainteresowany - gdzie wykopałeś format 'is (item, typedef)' w przeciwieństwie do formatu na wszystkich stronach pomocy 'is.typedef (item)'? Możesz także spróbować "metod (as)" i kilku podobnych badań, aby zobaczyć, co się dzieje w szczególności z klasą "stepfun". –
@Carl Witthoft: Wyszukiwanie "R wymuszenie" prowadzi do [dokumentacji metody "as"] (https://stat.ethz.ch/R-manual/R-devel/library/methods/html/as. html). W tym miejscu znajduje się link ([setIs] (https://stat.ethz.ch/R-manual/R-devel/library/methods/html/is.html)) do [dokumentacji metody 'is'] (https://stat.ethz.ch/R-manual/R-devel/library/methods/html/is.html). – mra68