Hi,
This is a question from an R-newby!
I?ve got a very extensive data set and will need to run a large number of Mann-Whitney U tests (in R: wilcox.test) between several sets of data. I am trying to automate this as far as possible so I won?t need to run each test one by one. I asked already somebody for help which provided a short piece of code which enables me to run several tests one after another. However, I will need to re-adjust this code as there are missing values and it stops every time it encounters this.
The data (I?ve attached a small file with some example data, so you can have an idea how it looks like and run code on it):
We?ve got bird density data from various locations, collected over the course of several years. One location (?0?) is our control, which is supposed to be tested against each of the other locations (?1? ? ?3?). We would like to run this test only on data collected during the same year, so we would test ?0? vs ?1? in 1980, ?0? vs ?1? in 1981 etc.
This is the code I?ve got so far and which works fine as long as there exists data from all years in all locations:
for(i in 1980:1983){
for(j in 1:3){
tmp<- d[d$year == i & d$hotspot %in% c(0, j), ]
print(c(i, j))
print(wilcox.test(densities~factor(hotspot), data= tmp))
}
}