I'm working with (un-paired/independent) environmental data collected over 2 consecutive months that I'd like to compare for each calendar year (CYR). I have many years and several months of data so running each test one by one is too tedious. I found a useful piece of code for running multiple Kruskal-Wallis tests, but given that the Wilcoxon only compares 2 groups at once and my groups (Month or Month2) change slightly per year (depending on when data were collected) this code won't work - that I know of. Thanks in advance!
# Kruskal-Wallis code (hoping for something like this using wilcoxon test instead):
by(dry_season, dry_season$CYR, function(z) kruskal.test(temp ~ Month2, data = z))
# With these settings (March and April are just examples from my data):
wilcox.test(March, April, mu=0, alt="two.sided", paired=F, conf.int=T, conf.level=0.8, exact = F, correct = F)
# Data:
> dput(dry_season)
structure(list(use_for_analysis = structure(c(3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L,
3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,
3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 1L,
1L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,
3L, 3L, 1L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L,
1L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
1L, 1L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 1L, 3L, 1L, 3L, 3L, 3L, 3L, 1L, 3L, 1L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 1L, 3L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022"), class = "factor"), Season = c("DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY", "DRY",
"DRY"), Month = c(3, 2, 3, 2, 3, 2, 2, 3, 2, 3, 3, 4, 4, 3, 4,
3, 3, 2, 3, 2, 3, 2, 3, 3, 4, 3, 4, 4, 4, 3, 3, 3, 2, 3, 3, 2,
2, 3, 2, 3, 3, 3, 3, 4, 3, 3, 3, 4, 3, 4, 3, 4, 3, 3, 3, 2, 3,
2, 3, 3, 2, 3, 3, 2, 4, 3, 3, 2, 3, 2, 3, 2, 3, 4, 4, 3, 3, 4,
3, 3, 4, 3, 3, 4, 3, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, 3, 4, 2, 3,
3, 3, 4, 2, 3, 4, 3, 3, 2, 3, 3, 4, 4, 3, 3, 3, 3, 2, 2, 3, 2,
4, 4, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2, 4, 3, 4, 3, 2, 4, 4,
3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 4, 2, 3, 3, 3, 3, 2, 3, 3, 3,
3, 4, 4, 3, 4, 3, 3, 3, 3, 3, 3, 3, 2, 3, 4, 3, 3, 3, 3, 3, 3,
4, 2, 4, 3, 2, 3, 4, 2, 3, 3, 4, 3, 3, 2, 4, 3, 3, 3, 3, 3, 3,
4, 3, 3, 3, 3, 3, 3, 2, 3, 4, 4, 3, 3, 2, 3, 3, 3, 3, 3, 4, 4,
3, 3, 4, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 4,
3, 3, 4, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 3, 4, 2, 3, 3, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
Site = c(17, 46, 27, 37, 18, 40, 45, 16, 47, 26, 29, 23,
17, 1, 9, 47, 19, 41, 16, 44, 15, 36, 17, 25, 6, 47, 8, 16,
22, 8, 40, 30, 42, 2, 20, 31, 35, 18, 43, 14, 24, 11, 16,
21, 15, 7, 31, 15, 46, 6, 31, 13, 41, 39, 21, 43, 14, 42,
3, 41, 34, 23, 47, 47, 8, 45, 10, 30, 19, 40, 32, 39, 15,
20, 14, 6, 21, 5, 22, 38, 12, 39, 46, 7, 4, 33, 44, 30, 13,
29, 44, 13, 38, 22, 14, 9, 13, 41, 33, 20, 23, 4, 46, 17,
19, 8, 20, 39, 46, 45, 5, 7, 38, 12, 12, 29, 37, 32, 5, 28,
12, 3, 5, 24, 40, 45, 21, 8, 37, 43, 34, 19, 21, 45, 18,
45, 4, 7, 38, 11, 6, 28, 11, 37, 13, 44, 25, 46, 31, 36,
4, 27, 2, 36, 42, 27, 20, 18, 44, 39, 22, 18, 35, 3, 10,
34, 11, 44, 10, 27, 36, 12, 35, 6, 47, 43, 17, 3, 41, 11,
26, 6, 19, 10, 26, 1, 36, 35, 38, 2, 30, 26, 26, 5, 19, 34,
43, 9, 35, 40, 33, 43, 23, 10, 16, 7, 27, 5, 37, 25, 2, 39,
42, 4, 1, 18, 33, 29, 9, 20, 37, 42, 9, 15, 8, 11, 25, 3,
25, 24, 28, 34, 42, 34, 14, 32, 32, 21, 1, 28, 12, 10, 24,
23, 22, 2, 33, 31, 14, 33, 41, 31, 38, 15, 3, 13, 9, 23,
22, 24, 1, 36, 7, 40, 30, 32, 32, 24, 2, 30, 35, 16, 25,
29, 1, 28, 17, 26, 29, 27, 28, 4, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47), temp = c(24.7, 24.7,
24.3, 24.8, 23.5, 26.3, 24.2, 24.6, 24.1, 24.6, 22.5, 25.8,
23.2, 25.4, 23.7, 25.8, 23.9, 25.6, 18.66, 25.7, 24.8, 24.6,
21.36, 24, 24.7, 20.9, 24, 23.3, 25.7, 22.5, 24.8, 23.5,
25.3, 26.3, 23.9, 25.03, 24.9, 21.58, 25.6, 24.7, 24.5, 25.4,
22.4, 25.9, 19.24, 23.4, 23.4, 23.2, 20.5, 25.3, 26.3, 22.5,
25, 22.2, 24, 26, 19.32, 24.5, 25.8, 23.2, 25.7, 24.8, 26,
23.6, 21.7, 19.9, 25.4, 25.57, 21.95, 27.1, 23.9, 24.9, 21.9,
24.6, 23.8, 24.2, 26.1, 24.7, 24, 21.6, 22.9, 27.4, 26.3,
25.2, 25.6, 25.4, 25.3, 26.4, 19.48, 25.82, 21.4, 25, 25.15,
25.2, 22.3, 26.1, 24.1, 25.8, 24.1, 23.04, 23.6, 24.6, 24.18,
22.9, 26, 22.85, 26, 27.3, 26.9, 26.6, 25, 22.4, 28.4, 19.79,
25.3, 26.3, 25.72, 24.8, 26.6, 25.29, 24.1, 25.1, 25.1, 23.5,
23.1, 24.9, 25.7, 26.4, 21.5, 20.8, 24.3, 26.2, 23.82, 23.9,
26.1, 27, 25.8, 23.37, 28.5, 23.9, 23.2, 26.2, 20.55, 26.6,
22.5, 26.2, 23.6, 25.1, 25.4, 22.4, 24.8, 26.04, 25.3, 25.88,
21.8, 28.6, 25.5, 26.8, 24.51, 23.7, 24.02, 22.9, 24.4, 25.9,
23.3, 28.2, 25, 26.3, 21, 26.7, 28.6, 22.5, 22.3, 26.5, 26.5,
28, 25.9, 25.5, 21.5, 25.8, 23.6, 23.79, 26.1, 24.7, 27.16,
25.5, 24.3, 26.97, 23.7, 26.2, 25.8, 27.2, 29.9, 23.7, 23,
21.5, 24.93, 24.5, 28.6, 22.1, 28.3, 27.4, 24.17, 25.8, 26.1,
26.8, 24.1, 23.66, 24.3, 26.6, 24.5, 27.3, 28.1, 24.2, 26.6,
25.8, 22.4, 26.2, 22.13, 24.5, 24, 27.2, 26.9, 25.3, 24.8,
22.6, 29.5, 24.7, 28.06, 27.1, 24.3, 27.37, 25.89, 26, 27.5,
28.7, 22.3, 24.2, 26, 26.7, 26.8, 22, 29.2, 27.7, 24, 24.4,
27.9, 22.7, 27.2, 28.09, 26.83, 28.4, 25.3, 27, 25.52, 27.9,
23.4, 24.6, 27.4, 28.3, 24.9, 24.4, 26.1, 26.58, 23.6, 28.3,
28.94, 24.4, 26.3, 29.5, 24.6, 28.1, 25.9, 24.6, 26.48, 24.8,
28.5, 25.3, 29.9, 24.6, 29.3, 24.46, 20, 20, 19, 20, 20,
19, 23, 21, 22, 21, 21, 20, 19, 19, 19, 19, 20, 19, 20, 17,
18, 19, 19, 20, 20, 19, 18, 17.5, 19, 19, 19, 19, 18, 18,
19, 19, 19, 19, 20, 20, 19, 20, 20, 20, 20, 21, 21), sal = c(21.29,
33.36, 15.14, 21.77, 25.37, 22.98, 32.4, 22.6, 32.12, 15.49,
20.52, 11.92, 27.33, 28.37, 30.53, 34.62, 24.45, 22.04, 32.48,
33.58, 25.2, 20.77, 27.89, 11.36, 23.64, 28.55, 31.21, 27.49,
13.21, 29.39, 31.54, 21.53, 23.25, 27.55, 22.52, 23.99, 20.4,
25.94, 32.65, 26.36, 11.76, 25.08, 24.33, 13.2, 32.46, 29.36,
22.7, 27.51, 30.08, 31.35, 27.92, 20.49, 32.29, 19.09, 20.72,
25.37, 32.41, 29.26, 28.22, 20.01, 20.07, 11.69, 26.48, 25.8,
30.29, 30.64, 25.47, 25.88, 24.12, 32.13, 22.37, 29.3, 24.44,
12.71, 28.69, 29.94, 25.05, 25.01, 20.79, 13.21, 21.48, 31.62,
33.74, 31.89, 28.01, 20.16, 23.74, 27.41, 32.55, 26.18, 27.49,
27.94, 27.29, 12.98, 26.13, 25.97, 29.49, 25.37, 22.47, 24.47,
20.04, 25.29, 26.56, 23.94, 15.42, 31.41, 24.39, 28.7, 26.42,
33.79, 30.42, 29.19, 31.53, 31.66, 28.33, 25.14, 26.8, 17.55,
27.37, 26.61, 29.8, 25.43, 30.31, 20.04, 17.71, 21.32, 13.05,
26.14, 17.23, 28.6, 22.52, 23.33, 19.29, 26.6, 13.54, 28.12,
31.57, 29.08, 27.46, 22.86, 22.71, 24.7, 32.59, 29.62, 28.31,
33.71, 19.66, 21.39, 16.24, 17.31, 30.67, 24.28, 25.54, 26.56,
26.9, 15.19, 16.56, 22.54, 26.2, 8.76, 19.63, 21.29, 22.82,
31.26, 22.2, 17.99, 30.07, 26.71, 29.02, 25.31, 29.7, 28.69,
17.48, 27.75, 27.64, 33.26, 18.74, 30.66, 28.05, 28.95, 19.8,
33.7, 13.48, 30.12, 24.23, 25.18, 22.57, 25.72, 7.88, 30.94,
15.33, 25.33, 15.89, 26.62, 15.4, 18.21, 27.07, 22.95, 29.72,
27.77, 18.55, 28, 19, 29.13, 18.57, 28.48, 20.25, 34, 21.65,
23.11, 29.77, 20.19, 32.93, 29.61, 32.25, 15.67, 18.5, 15.12,
30.52, 12.57, 9.62, 28.82, 29.05, 16.39, 23.45, 29.5, 10.56,
29.33, 23.72, 23.66, 20.33, 25.49, 25.69, 27.77, 25.3, 17.2,
20.69, 12.68, 30.88, 14.86, 24.92, 29.62, 8.06, 22.97, 13.57,
27.39, 27.45, 21.81, 16.97, 24.86, 26.03, 17.07, 15.57, 25.08,
33.34, 25.08, 29.94, 14.42, 23.65, 24.78, 30.59, 10.25, 24.55,
26.69, 23.37, 26.26, 25.24, 16.62, 31.83, 17.7, 10.51, 24.08,
17.45, 22.16, 32.63, 21.56, 23.51, 21.5, 14.04, 21.57, 13.7,
32.12, 37, 40, 38, 37, 38, 37, 28, 35, 32, 35, 36, 39, 36,
37, 35, 38, 36, 37, 38, 36, 31, 30, 28, 28, 28, 35, 31, 32,
31, 34, 34, 34, 25, 30, 25, 35, 35, 35, 34, 34, 32, 33, 32,
34, 33, 34, 34), DO = c(5.2, 2.7, 5.3, 4, 4.98, 5.04, 4,
5.4, 5, 6.1, 4.29, 4.68, 4.2, 6.51, 3.17, 4.91, 5.02, 4.24,
5.99, 4.5, 4.9, 5, NA, 5.9, 3.56, 5.7, 3.22, 5.2, 5.25, 5.9,
2.4, 4.45, 5.61, 5.42, 6.03, 4.47, 5.6, 9.91, 5.2, 5.9, 6.7,
2.05, 3.74, 6.4, NA, 5.5, 4.77, 7.07, 6.57, 5.17, 2.16, 4.4,
3.85, 5.05, 5.68, 4.74, NA, 6.8, 5.66, 5.57, 5.5, 6.9, 5.05,
7.89, 4.29, 6.78, 3.02, 4.48, 5.73, 5.3, 5.16, 5.96, 5.23,
7.16, 3.92, 4.9, 4.94, 6.7, 5.73, 7.05, 4.46, 3.53, 5.45,
5.05, 7.64, 6.2, 6.19, 4.09, NA, 4.61, 6.69, 5.1, 5.76, 7.2,
4.85, 4.09, 4.69, 10.2, 4.55, 9.87, 5.94, 6.96, 7.25, 6.65,
5.8, NA, 5.64, 5.5, 7.26, 6.83, 3.35, 5.48, 4.15, NA, 5.4,
3.59, 6.69, 5.3, 5.45, 6.22, 4.4, 7.98, 6.1, 6.07, 8.14,
6.45, 7.6, 5.72, 6.94, 7.13, 4.6, 5.03, 6.32, 7.21, 6.88,
8.69, 10.57, NA, 6.6, 7.05, 5.63, 5.41, NA, 3.61, 5.48, 6.42,
5.97, 6.94, 6.1, 8.26, 7.5, 6.06, 8.04, 6.07, 7.49, 4.94,
8.1, 5.52, 8.33, 8.82, 9.2, 7.63, 5.73, 4.69, 5.14, 7.18,
4.6, 7.32, NA, 5.33, 5.9, 5.83, 7.49, 5.21, 6.17, 7.99, 10.5,
7.2, 7.62, 5.3, 6.01, NA, 8.4, 3.92, 8.61, 7.85, 5.16, 7.28,
8.68, 3.79, 7.2, 6.19, 7.29, 5.72, 9.48, 7.15, 8.29, 7.8,
7.33, 7.66, 12.55, 9.88, 10.38, 5.3, 11.45, 4.45, 5.54, NA,
5.41, 4.52, 5.5, 6.73, 9.1, 8.15, 7.59, 9.4, 9.98, 7.7, NA,
9.3, 8.94, 9.74, 7.8, 8.95, 9.32, 7.25, 7.12, 8.11, 6.76,
5.75, 5.34, 7, 9.45, 6.19, 5.56, 7.84, 7.03, 9.26, 7.7, 8.6,
4.59, 6.01, 6.47, 7.6, 8.97, 5.17, 6.42, 7.32, 12.07, 8.38,
8.58, 7.2, 5.88, 4.77, NA, 8.23, 8.19, 12.67, 8.45, 8.76,
6.38, 9.51, 11.91, 8.1, 7.77, 5.58, 10.13, 10.21, NA, 11.72,
9.22, 7.87, 14.43, 9.22, NA, 9.88, 7.36, 10.71, 7.92, 7.42,
8.09, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA), water_depth = c(70, 45, 64, 76, 68,
95, 75, 91, 65, 84, 80, 80, 55, 98, 51, 97, 85, 92, 62, 65,
98, 98, 58, 83, 68, NA, 60, 80, 92, 68, 95, 85, 143, 108,
112, 72, 101, 63, 80, 106, 103, 75, 51, 85, 49, 85, 101,
72, NA, 70, 90, 117, 95, 81, 103, 98, 58, 53, 107, 72, 106,
102, 85, 74, 63, NA, 73, 70, 62, 81, 113, 79, 68, 96, 79,
90, 86, 95, 118, 86, 128, 101, 42, 70, 143, 95, 68, 100,
52, 60, NA, 90, 52, 102, 69, 84, 90, 43, 110, 64, 109, 96,
62, 99, 80, 110, 105, 90, 52, 83, 70, 80, 91, 40, 110, 105,
59, 96, 97, 56, 85, 102, 105, 113, 87, 98, 91, 75, 86, NA,
118, 103, 63, 84, 63, 62, 52, 115, 55, 83, 88, 104, 33, 78,
74, 43, 94, 59, 80, 80, 100, 50, 120, 72, NA, 30, 103, 98,
74, 95, 62, 79, 119, 62, 89, 57, 35, 53, 55, 85, 76, 88,
79, 75, 95, 45, 75, 79, NA, 74, 95, 65, 76, 50, 50, 95, 104,
35, 100, 62, 76, 78, 83, 88, 72, 75, 60, 60, 49, NA, 76,
50, 64, 73, 64, 83, 73, 80, 92, 64, 90, 78, 55, 64, 60, 57,
75, 71, 60, 48, 90, 67, 53, 67, 49, 65, 61, 77, 52, 60, 88,
68, 68, 70, 85, 75, 79, 64, 71, 57, 86, 52, 63, 70, 66, 82,
63, 60, 60, 70, 39, 77, 88, 84, 52, 98, 39, 50, 75, 62, 80,
75, 38, 72, 45, 66, 67, 50, 62, 80, 80, 70, 48, 59, 47, 70,
68, 65, 81, 46, 85, 49, 31, 29, 46, 41, 67, 42, 82, 80, 70,
68, 78, 52, 38, 30, 90, 90, 80, 83, 87, 75, 69, 28, 91, 108,
109, 80, 59, 68, 90, 90, 85, 80, 90, 90, 85, 95, 80, 80,
91, 89, 42, 78, 85, 72, 87, 90, 87), sed_depth = c(51, 4,
52, 47, 2, 45, 36, 39, 25, 54, 17, 18, 10, 45, 25, 78, 7,
69, NA, 105, 60, 35, NA, 58, 27, NA, 0, 15, 33, 6, 60, 29,
39, 22, 14, NA, 40, NA, 80, 34, 50, 19, 93, 33, NA, 39, 32,
15, NA, 50, 40, 4, 80, 92, 25, 72, NA, 27, 8, 73, 40, 66,
45, NA, 0, NA, 22, NA, NA, 46, 9, NA, 34, 27, 50, 47, 34,
21, 23, 54, 7, 49, 7, 60, 7, 28, 72, 36, NA, NA, NA, 30,
NA, 15, 87, 10, 10, 73, 59, NA, 23, 5, NA, 24, 25, NA, 15,
55, 4, 81, 25, 41, 61, NA, 35, 25, NA, 7, 5, NA, 15, 63,
25, 34, 73, 63, 32, 0, 45, NA, 25, 27, NA, NA, 0, 3, 5, NA,
61, 52, 32, 70, NA, 48, 53, 100, 30, 4, 37, 61, 9, NA, 10,
NA, NA, 75, 18, 18, NA, 75, NA, 1, 24, 33, 40, 35, 30, 100,
NA, 65, 50, 34, 58, 17, 45, 90, 19, 61, NA, 61, 33, NA, 13,
35, NA, 94, 42, NA, 57, 50, 26, 75, 27, 13, 40, 57, NA, 24,
61, NA, 9, 68, NA, 29, 43, 10.17, 21, NA, 30, 30, 38, 22,
90, 3, 60, 2, 14, 21, NA, 78, 42, 55, 30, 48, 0, 67, 69,
73, NA, 50, 23, NA, NA, 35, 29, 13, 53, 30, 74, 33, 1, 58,
43, 35, 30, 44, 26, 52, 35, NA, NA, 56, 45, 42, NA, 10, 21,
30, 30, NA, 73, 45, 57, NA, 63, 29, NA, 45, NA, 35, 38, 20,
35, 42, NA, 65, 24, 50, 5, 63, 15, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA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L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 2L, 4L, 3L, 4L, 2L, 3L, 3L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), levels = c("Jan",
"Feb", "Mar", "Apr"), class = "factor")), row.names = c(NA,
-329L), class = c("tbl_df", "tbl", "data.frame"))
CodePudding user response:
This will run the analysis for the temp
data and should give you what you need to get the other variables you want. First we need to get rid of the empty factor levels in CYR
:
dry_season <- droplevels(dry_season)
Now split the data and get rid of the empty factor levels in Month2
:
dry_season.splt <- split(dry_season, dry_season$CYR)
dry_season.splt <- lapply(dry_season.splt, droplevels)
Now run the analysis for temp
results.temp <- lapply(dry_season.splt, function(x) wilcox.test(temp~Month2, x, conf.int=TRUE, conf.level=0.8, exact=FALSE, correct=FALSE))
names(results.temp)
results.temp[["2005"]] # or results.temp[[1]]
#
# Wilcoxon rank sum test
#
# data: temp by Month2
# W = 87.5, p-value = 0.5245
# alternative hypothesis: true location shift is not equal to 0
# 80 percent confidence interval:
# -9.999840e-01 1.470944e-05
# sample estimates:
# difference in location
# -1.393135e-05
Just change temp
to the other variables to get their results.