0

I wrote a function to perform hypothesis testing. I will call it here myMethod.test. This function basically takes two samples x and y and returns a p value for my null hypothesis. I thus write a function :

myMethod.test<-function(x,y)
{.....}

I would like also to support expression as it is the case for base core test function e.g. t.test or wilcox.test in which you can write (measurement and group being two columns of data):

t.test(data,measurement~group)

I would like to find existing functions coded in pure R and supporting such call to adapt it to my case (or any other hints).

beuhbbb
  • 257
  • 3
  • 14
  • 1
    This is too broad to answer in general. It would be better if you provided a more concrete [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that can be used for testing. But functions like `wilcox.test` work because they are S3 generic functions in R. Functions in R can dispatch based on the `class()` of the first parameter. You can see the version that runs with a formula with `stats:::wilcox.test.formula` and the "default" version with `stats:::wilcox.test.default` – MrFlick Dec 17 '19 at 18:46
  • @MrFlick. Thanks this was basically what I looked for. – beuhbbb Dec 17 '19 at 19:31

0 Answers0