Writing a function to perform a non-parametric test

I want to write a function that includes a test that will perform either the wilcoxon rank sum test if the length of the unique number of levels is less than three or else perform the kruskal-wallis test. A function that would look like the below that I can apply to any variable:

Non.partest<-function(x, f, round=3){
if(XXXXXX){wilcox.test
}
else{kruskal.test

}
}

Any help would be appreciated

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.