简体   繁体   English

'arg'必须为NULL或字符向量

[英]'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.

相关问题 警告:match.arg中的错误:'arg'必须为NULL或字符向量 - Warning: Error in match.arg: 'arg' must be NULL or a character vector match.arg(regions) 中的错误:“arg”必须为 NULL 或字符向量 - Error in match.arg(regions) : 'arg' must be NULL or a character vector T 检验错误 'arg' 必须是 NULL 或字符向量 - T-test error 'arg' must be NULL or a character vector match.arg(opt_crit)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(opt_crit) : 'arg' must be NULL or a character vector 运行应用程序时出现闪亮错误:match.arg(position) 中的错误:'arg' 必须为 NULL 或字符向量 - Shiny Error when running App: Error in match.arg(position) : 'arg' must be NULL or a character vector Shiny 应用程序中的“match.arg(position) 错误:‘arg’必须为 NULL 或字符向量” - "Error in match.arg(position) : 'arg' must be NULL or a character vector" in Shiny app match.arg(p.adjust.method)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(p.adjust.method) : 'arg' must be NULL or a character vector match.arg(position) 中的闪亮错误:“arg”必须为 NULL 或字符向量 - shiny Error in match.arg(position) : 'arg' must be NULL or a character vector 尝试运行以下代码中的插补函数时,“match.arg(what) 中的错误:'arg' 必须为 NULL 或字符向量” - "Error in match.arg(what) : 'arg' must be NULL or a character vector" when trying to run the impute function in the below code 使用 parApply 时如何纠正“第一个错误:'arg' 必须是 NULL 或字符向量”? - How to correct “first error: 'arg' must be NULL or a character vector” when using parApply?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM