I have a problem with the lapply function and I did not find any matching question posted earlier.
I need to apply a permutation test to all list elements, however I am not able to setup the lapply correctly.
I am trying this
testperm <- lapply(test-list, FUN=perm.test, formula=(cover ~ group))
the function perm.test is from the package ‘exactRankTests’
cover is the dependent (numerical) variable and group is a factor.
Any hints on how to apply such a function would be very much appreciated.
jens
When you use a formula, you often also need to supply a value to a
dataargument so the function knows which data to use. You data sets will be the list elements, so you need to use an anonymous function to supply them to perm.test.In this case try: