MYaseen208
MYaseen208

Reputation: 23898

Getting arguments of S3 method in R

I get see the argument of any R function with args function, like

args(cor)
function (x, y = NULL, use = "everything", method = c("pearson", 
    "kendall", "spearman")) 
NULL

However, not able to see the arguments of cor.test. See this example:

args(cor.test)
function (x, ...) 
NULL

Edited

However the arguments of cor.test are

cor.test(x, ...)

## Default S3 method:
cor.test(x, y,
         alternative = c("two.sided", "less", "greater"),
         method = c("pearson", "kendall", "spearman"),
         exact = NULL, conf.level = 0.95, continuity = FALSE, ...)

## S3 method for class 'formula'
cor.test(formula, data, subset, na.action, ...)

I want to extract

cor.test(x, y,
         alternative = c("two.sided", "less", "greater"),
         method = c("pearson", "kendall", "spearman"),
         exact = NULL, conf.level = 0.95, continuity = FALSE, ...)

Upvotes: 0

Views: 308

Answers (1)

Consistency
Consistency

Reputation: 2922

In R version 3.4, although cor.test is exported by package stats, S3 methods like cor.test.default and cor.test.formula is not exported, so you need to use stats::: to access them and then you can use arg to get their arguments like args(stats:::cor.test.default).

Or you can use argsAnywhere to get arguments for functions and methods no matter where it is like argsAnywhere(cor.test.default).

Upvotes: 4

Related Questions