Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R function-- the default value does not work?

Tags:

r

I am really new to R. Allow me to ask a beginner's question.

When I type p.adjust, for example, I can see the following. It seems that the argument method is p.adjust.methods by default. I tried to trace the code but when I typed something like:

match.arg(p.adjust.methods)

It says:

Error in match.arg(p.adjust.methods) : 'arg' must be of length 1

Why?

> p.adjust
function (p, method = p.adjust.methods, n = length(p)) 
{
    method <- match.arg(method)
    ...
}
like image 845
Daniel Avatar asked Mar 22 '23 04:03

Daniel


1 Answers

The match.arg function does not work in interactive mode in its one argument form, since there is nothing to match to. That first argument is expected to be a length 1 character vector, and it is tested against the known methods _inside_the_function_:

> ?p.adjust
> p.adjust.methods
[1] "holm"       "hochberg"   "hommel"     "bonferroni" "BH"         "BY"         "fdr"       
[8] "none"     

(The first argument to p.adjust if you are using positional matching needs to be a vector of p-values.)

like image 56
IRTFM Avatar answered Mar 29 '23 23:03

IRTFM