R:怎么会这样;是";是真的,但是;作为「;这是不可能的吗?
继承自类“stepfun”。如果R:怎么会这样;是";是真的,但是;作为「;这是不可能的吗?,r,R,继承自类“stepfun”。如果f是这样一个经验累积密度函数, 和都是.stepfun(f)和都是(f,“stepfun”)都是真的,而都是。stepfun(f)没有按预期做任何事情。 但是,由于“元数据”的原因,f无法通过as(f,“stepfun”)将f转换为“stepfun”,即使strict为FALSE: f <- ecdf(1:10) class(f) # [1] "ecdf" "stepfun" "function" is.stepfun(f) # [1] TRU
f
是这样一个经验累积密度函数,
和都是.stepfun(f)
和都是(f,“stepfun”)
都是真的
,而都是。stepfun(f)
没有按预期做任何事情。
但是,由于“元数据”的原因,f
无法通过as(f,“stepfun”)
将f
转换为“stepfun”,即使strict
为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
f我可能找到了一些相关信息。
在
本地:-)有关于尝试使用as()的警告
所以我的建议是坚持使用as.stepfun(foo)
你是说is.stepfun(f)
紧跟在class(f)
之后吗?我很感兴趣-你从哪里找到了格式is(item,typedef)
而不是所有帮助页面中的格式is.typedef(item)
?您可能还想尝试方法(as)
和一些类似的调查,以了解stepfun
类的具体情况。@Carl Witthoft:搜索“R强制”会导致错误。其中有一个链接()指向。
but it has two problems:
1) as() is an S4 method that does not always work
(problem 2 not relevant)