R: How is it that β€œis” TRUE, but β€œhow” is impossible?

the ecdf class inherits from the stepfun class. If f is such an empirical cumulative density function, both is.stepfun(f) and is(f,"stepfun") are TRUE , and as.stepfun(f) does nothing as expected. But converting f to "stepfun" to as(f,"stepfun") not possible because of the "metadata", even if strict is FALSE :

 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 

So, how is related to as and what is the meaning of "metadata" here?

+5
source share
1 answer

Perhaps I found some relevant information. To this nabble archive

 but it has two problems: 1) as() is an S4 method that does not always work (problem 2 not relevant) 

Locally :-) this SO question contains warnings about trying to use as()

So my suggestion would be to stick with as.stepfun(foo) .

+2
source

Source: https://habr.com/ru/post/1241613/


All Articles