Reputation: 13
I try to generate t.test for 12 dataframes. I try to create a list by doing
MyList <- list(data1,data2,data3...,data12)
and use lapply to to the t.test. But it is not working. I really don't know what to write...:(
Upvotes: 1
Views: 71
Reputation: 887831
We can use mget
to get all the datasets into a list
MyList <- mget(ls(pattern = "^data\\d+"))
then loop over the list
and apply t.test
lapply(MyList, function(x) t.test(x$yourcolumn1, x$yourcolumn2))
Make changes with the column name (assuming that the test is applied to the same columns - not clear)
Upvotes: 2