如何修复 R 中没有缺失值的 t.test 错误消息?
How to fix my t.test error message in R that has no missing value?
我的数据框如下:
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 测试,并且有 none。
你能帮帮我吗?
很抱歉这个非常低级的问题,但没有在 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 package (v2.0.1)
于 2022-05-17 创建
我的数据框如下:
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 测试,并且有 none。
你能帮帮我吗? 很抱歉这个非常低级的问题,但没有在 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 package (v2.0.1)
于 2022-05-17 创建