我的数据框如下:
Df <- structure(list(SES = c("High", "High", "High", "Low", "High",
"Low", "High", "High", "High", "Low", "Low", "Low", "High", "High",
"Low", "High", "High", "Low", "High", "High", "Low", "High",
"Low", "Low", "Low", "Low", "High", "Low", "High", "Low", "High",
"High", "Low", "High", "Low", "High", "High", "High", "Low",
"High", "High", "Low", "Low", "High", "Low", "Low", "Low", "Low",
"High", "High", "Low", "High"), entry_age = c(12, 2.5, 7, 2.5,
2.5, 12, 9, 2.5, 3, 8, 12, 2.5, 5.5, 6, 2.5, 2.5, 2.5, 16, 12,
5, 7, 2.5, 12, 2.5, 2.5, 12, 12, 12, 6, 24, 2.5, 2.5, 2, 3.5,
2.5, 2.5, 2.5, 4, 7, 12, 7, 9, 12, 6, 18, 15, 8, 12, 2.5, 6,
10, 5)), row.names = c(NA, -52L), class = c("tbl_df", "tbl",
"data.frame"))
我的均值有很大差异,并且想使用 t.test 函数通过 t 检验来测试其显着性,如下所示:
t.test(Df$SES, Df$entry_age)
非常简单,没什么复杂的。 但是,我得到的是以下错误代码,我不明白:
Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(x) :
l'argument n'est ni numérique, ni logique : renvoi de NA
2: In var(x) : NAs introduced by coercion
我进行了 NA 测试,但没有。
你能帮我一下吗? 很抱歉这个非常低级的问题,但在 Google 中没有找到此错误消息的含义。
你将得到我无尽的感激
看
help('t.test')
了解用法;按照您的调用方式,它期望测试组 x=Df$SE (这不是您想要的)和 y=Df$entry_age 之间的值。那么试试这个:
Df <- structure(list(SES = c("High", "High", "High", "Low", "High",
"Low", "High", "High", "High", "Low", "Low", "Low", "High", "High",
"Low", "High", "High", "Low", "High", "High", "Low", "High",
"Low", "Low", "Low", "Low", "High", "Low", "High", "Low", "High",
"High", "Low", "High", "Low", "High", "High", "High", "Low",
"High", "High", "Low", "Low", "High", "Low", "Low", "Low", "Low",
"High", "High", "Low", "High"), entry_age = c(12, 2.5, 7, 2.5,
2.5, 12, 9, 2.5, 3, 8, 12, 2.5, 5.5, 6, 2.5, 2.5, 2.5, 16, 12,
5, 7, 2.5, 12, 2.5, 2.5, 12, 12, 12, 6, 24, 2.5, 2.5, 2, 3.5,
2.5, 2.5, 2.5, 4, 7, 12, 7, 9, 12, 6, 18, 15, 8, 12, 2.5, 6,
10, 5)), row.names = c(NA, -52L), class = c("tbl_df", "tbl",
"data.frame"))
t.test(entry_age~SES, data=Df)
#>
#> Welch Two Sample t-test
#>
#> data: entry_age by SES
#> t = -2.9888, df = 35.479, p-value = 0.005059
#> alternative hypothesis: true difference in means between group High and group Low is not equal to 0
#> 95 percent confidence interval:
#> -6.695627 -1.280563
#> sample estimates:
#> mean in group High mean in group Low
#> 5.303571 9.291667
由 reprex 包于 2022 年 5 月 17 日创建(v2.0.1)
我在 agricolae 中的 waller.test 中遇到了类似的错误。我试图追踪它,但我完全无法纠正它。
这是我的数据框的一瞥:
print(obj1)
ID code bp stage dose rep day numberinitiated numberhealth numberdead
1 1 BAA n a A 1 0 10 10 0
2 2 BAA n a A 2 0 10 10 0
3 3 BAA n a A 3 0 10 10 0
4 4 BPA n p A 1 0 10 10 0
5 5 BPA n p A 2 0 10 10 0
6 6 BPA n p A 3 0 10 10 0
7 7 BLA n l A 1 0 10 10 0
8 8 BLA n l A 2 0 10 10 0
9 9 BLA n l A 3 0 10 10 0
10 10 BAF b a F 1 0 10 10 0
11 11 BAF b a F 2 0 10 9 1
12 12 BAF b a F 3 0 10 10 0
13 13 BPF b p F 1 0 10 9 1
14 14 BPF b p F 2 0 10 10 0
15 15 BPF b p F 3 0 10 9 1
16 16 BLF b l F 1 0 10 9 1
17 17 BLF b l F 2 0 10 9 1
18 18 BLF b l F 3 0 10 7 3
19 19 BAE b a E 1 0 10 6 4
20 20 BAE b a E 2 0 10 6 4
21 21 BAE b a E 3 0 10 6 4
22 22 BPE b p E 1 0 10 1 9
23 23 BPE b p E 2 0 10 3 7
24 24 BPE b p E 3 0 10 2 8
25 25 BLE b l E 1 0 10 8 2
26 26 BLE b l E 2 0 10 6 4
27 27 BLE b l E 3 0 10 7 3
28 28 BAD b a D 1 0 10 0 10
29 29 BAD b a D 2 0 10 1 9
30 30 BAD b a D 3 0 10 2 8
31 31 BPD b p D 1 0 10 6 4
32 32 BPD b p D 2 0 10 0 10
33 33 BPD b p D 3 0 10 0 10
34 34 BLD b l D 1 0 10 9 1
35 35 BLD b l D 2 0 10 5 5
36 36 BLD b l D 3 0 10 7 3
37 37 BAC b a C 1 0 10 9 1
38 38 BAC b a C 2 0 10 9 1
39 39 BAC b a C 3 0 10 8 2
40 40 BPC b p C 1 0 10 6 4
41 41 BPC b p C 2 0 10 9 1
42 42 BPC b p C 3 0 10 8 2
43 43 BLC b l C 1 0 10 7 3
44 44 BLC b l C 2 0 10 8 2
45 45 BLC b l C 3 0 10 8 2
46 46 BAB b a B 1 0 10 0 10
47 47 BAB b a B 2 0 10 0 10
48 48 BAB b a B 3 0 10 1 9
49 49 BPB b p B 1 0 10 5 5
50 50 BPB b p B 2 0 10 0 10
51 51 BPB b p B 3 0 10 0 10
52 52 BLB b l B 1 0 10 0 10
53 53 BLB b l B 2 0 10 10 10
54 54 BLB b l B 3 0 10 0 10
55 55 MAF m a F 1 0 10 10 0
56 56 MAF m a F 2 0 10 10 0
57 57 MAF m a F 3 0 10 10 0
58 58 MPF m p F 1 0 10 10 0
59 59 MPF m p F 2 0 10 10 0
60 60 MPF m p F 3 0 10 10 0
61 61 MLF m l F 1 0 10 10 0
62 62 MLF m l F 2 0 10 10 0
63 63 MLF m l F 3 0 10 10 0
64 64 MAE m a E 1 0 10 10 0
65 65 MAE m a E 2 0 10 10 0
66 66 MAE m a E 3 0 10 10 0
67 67 MPE m p E 1 0 10 10 0
68 68 MPE m p E 2 0 10 10 0
69 69 MPE m p E 3 0 10 10 0
70 70 MLE m l E 1 0 10 10 0
71 71 MLE m l E 2 0 10 10 0
72 72 MLE m l E 3 0 10 10 0
73 73 MAD m a D 1 0 10 10 0
74 74 MAD m a D 2 0 10 10 0
75 75 MAD m a D 3 0 10 10 0
76 76 MPD m p D 1 0 10 10 0
numberinfected event PctMrt
1 0 0 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 0 0 0
9 0 0 0
10 0 0 0
11 0 0 10
12 0 0 0
13 0 0 10
14 0 0 0
15 0 0 10
16 0 0 10
17 0 0 10
18 0 0 30
19 0 0 40
20 0 0 40
21 0 0 40
22 0 0 90
23 0 0 70
24 0 0 80
25 0 0 20
26 0 0 40
27 0 0 30
28 0 0 100
29 0 0 90
30 0 0 80
31 0 0 40
32 0 0 100
33 0 0 100
34 0 0 10
35 0 0 50
36 0 0 30
37 0 0 10
38 0 0 10
39 0 0 20
40 0 0 40
41 0 0 10
42 0 0 20
43 0 0 30
44 0 0 20
45 0 0 20
46 0 0 100
47 0 0 100
48 0 0 90
49 0 0 50
50 0 0 100
51 0 0 100
52 0 0 100
53 0 0 0
54 0 0 100
55 0 0 0
56 0 0 0
57 0 0 0
58 0 0 0
59 0 0 0
60 0 0 0
61 0 0 0
62 0 0 0
63 0 0 0
64 0 0 0
65 0 0 0
66 0 0 0
67 0 0 0
68 0 0 0
69 0 0 0
70 0 0 0
71 0 0 0
72 0 0 0
73 0 0 0
74 0 0 0
75 0 0 0
76 0 0 0
这是代码:
Effmodel <- lm(event ~ dose, data = obj1)
summary(Effmodel)
anovaEff <- anova(Effmodel)
waller.test (Effmodel, "dose", group = TRUE)
这是错误:
waller.test (Effmodel, "dose", group = TRUE)
Error in if ((K - IN0/ID0) * (K - IN1/ID1) <= 0) b0 <- t :
missing value where TRUE/FALSE needed
请帮助我,因为我已经被困了 4 个小时并且谷歌搜索错误没有帮助。