[英]'arg' must be NULL or a character vector
Here's a prop.test function: 这是一个prop.test函数:
baby.prop.test = function (x, n, p, conf.level = 0.95) {
# ...
return(prop.test(x,n,p,conf.level))
#baby.prop.test$statistic
}
# test case
baby.prop = baby.prop.test(72, 100, .7, conf.level=.99)
stopifnot(isTRUE(all.equal(as.numeric(baby.prop$statistic), .43643578)))
stopifnot(isTRUE(all.equal(as.numeric(baby.prop$p.value), .66252058)))
Here is the error: 这是错误:
Error in match.arg(alternative) :
'arg' must be NULL or a character vector
Any idea what's wrong? 知道有什么问题吗?
According to formals(prop.test)
or ?prop.test
the fourth argument is called alternative
and has to be a character of c("two.sided", "less", "greater")
. 根据formals(prop.test)
或?prop.test
,第四个参数称为alternative
,并且必须是c("two.sided", "less", "greater")
的字符。 Your fourth element is conf.level
(which is the fifth of prop.test
, the order matters). 您的第四个元素是conf.level
(这是conf.level
的第五个prop.test
,顺序很重要)。 To "ignore" the order of arguments you have to name your arguments (at least the conf.level
): 要“忽略”参数的顺序,必须命名参数(至少是conf.level
):
prop.test(x, n, p, conf.level=conf.level)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.