'arg' must be NULL or a character vector

34,209

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"). Your fourth element is conf.level (which is the fifth of prop.test, the order matters). To "ignore" the order of arguments you have to name your arguments (at least the conf.level):

prop.test(x, n, p, conf.level=conf.level)
Share:
34,209
Mona Jalal
Author by

Mona Jalal

contact me at [email protected] I am a 5th-year computer science Ph.D. Candidate at Boston University advised by Professor Vijaya Kolachalama in computer vision as the area of study. Currently, I am working on my proposal exam and thesis on the use of efficient computer vision and deep learning for cancer detection in H&E stained digital pathology images.

Updated on March 04, 2020

Comments

  • Mona Jalal
    Mona Jalal over 4 years

    Here's a prop.test function:

    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?