1

I wanted to access the source code of the wilcox.test function in R (my R GUI: Revolution R Enterprise).

From the console:

> wilcox.test
function (x, ...) 
UseMethod("wilcox.test")
<environment: namespace:stats>

From Object Browser, right-click wilcox.test in stats package, and then clicking "edit" revealed:

function (x, ...) 
UseMethod("wilcox.test")

I wanted to know the source code since sometimes the wilcox.test command produced a value "V=...", sometimes it produced "W=...". The help file of wilcox.test does not explain what is V and W. Any help will be greatly appreciated.

I want a solution that requires no downloading R source code from CRAN or elsewhere; i.e., I want a solution within GUI (especially, Revo R Ent).

Erdogan CEVHER
  • 1,788
  • 1
  • 21
  • 40

1 Answers1

5

Here is a quick approach. Whenever you see methods, it means the function you call is a generic function. So do the following to list all methods it supports:

> methods(wilcox.test)
[1] wilcox.test.default* wilcox.test.formula*

Then you can try:

stats:::wilcox.test.default

or:

stats:::wilcox.test.formula

To print the function body into your R console.

  • Thx Oops. The `methods(wilcox.test)` produced [[ [1] wilcox.test.default* wilcox.test.formula* Non-visible functions are asterisked ]]. `stats:::wilcox.test.default` gave the exact long source code. `stats:::wilcox.test.formula` seems to be useful as well. – Erdogan CEVHER Jun 06 '16 at 09:33