Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:怎么会这样;是";是真的,但是;作为「;这是不可能的吗?_R - Fatal编程技术网

R:怎么会这样;是";是真的,但是;作为「;这是不可能的吗?

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

继承自类“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] 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)