I have the example data frame
test.df<-data.frame(classifier=runif(n=1000), x1=rnorm(1000), x2=rnorm(1000), x3=rnorm(1000))
with x1,x2,…,x10000
I would like to use the apply function to perform a large amount of tests (lets say t.test) and collect the results in a vector(lets say t.test()$p.value ). The test on a single column would be t.test(test.df$x1[ test.df$classifier<0.4 ], test.df$x1[ test.df$classifier>0.6 ])$p.value
I would like to perform this on all with x1,x2,…,x10000. I though I would use the apply function with MARGIN=2 but I cannot get the apply function to split every column vector according to the classifier.
(The example provided above has absolutely no statistical meaning. Don’t go viral)
Any help?
Is this what you want ?
Which gives :