我正在处理一个数据集,我需要将序数数据与不同列中的连续数据进行比较。即,个体被分类(实际上按年龄),我需要将不同的年龄范围与两个不同的测试值进行比较。我一直试图运行一个多因素的anova,并且没有运气。
首先,我对每个年龄类别进行了子集并尝试了这个:
aov.first.molar<-aov(carbon.combo~first.m.cat.1+first.m.cat.2+first.m.cat.3+first.m.cat.4+first.m.cat.5)
Error in model.frame.default(formula = carbon.combo ~ first.m.cat.1 + :
invalid type (list) for variable 'first.m.cat.1'
因此子集不起作用,所以我尝试使用列标题,只是为了看它是否会按类别神奇地组织......
> aov.albania.first<-aov(albania$AgeCat_first~albania$juv_deltaC_dentine+albania$Adult_deltaC_collagen)
Warning messages:
1: In model.response(mf, "numeric") :
using type = "numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
> summary(aov.albania.first)
Error in levels(x)[x] : only 0's may be mixed with negative subscripts
这显然也没有用,我不确定我做错了什么。我将一切都设置为一个因素,我不明白为什么代码不起作用。 我想知道它是否与我的测试数据的性质是负面的事实有关。我不知道如何在不改变数据的情况下解决这个问题
根据要求,这是我的数据。对不起它太乱了,我不知道如何更好地格式化它。把它变成一个矩阵有帮助,但我仍然遇到anov和ggplot无法找到我已经变成因素的某些事情的问题......
structure(list(Number = structure(1:10, .Label = c("142-c-1",
"142-c-3", "142-c-5", "156-c-1", "156-c-4", "156-c-6", "157-c-1",
"157-c-3", "157-c-5", "157-c-6", "158-c-3", "158-c-6", "178-c-1/A",
"178-c-2/A", "178-c-2/b", "178-c-3/b", "178-c-4/b", "186-c-2/a",
"186-c-2/b", "186-c-3/b", "186-c-4/b", "186-c-5/b", "186-c-6/b",
"192-c-1", "192-c-2", "192-c-3", "192-c-4", "192-c-5", "205-c-1",
"205-c-2", "205-c-3", "205-c-4", "205-c-5", "205-c-6", "210-c-1",
"210-c-2", "210-c-3", "210-c-4", "210-c-5", "215-c-1", "215-c-2",
"215-c-3", "215-c-4", "215-c-5", "215-c-6", "215-c-7", "270-c-1",
"270-c-2", "270-c-3", "270-c-4", "270-c-5", "295-c-1", "295-c-3",
"295-c-4", "353-c-2", "353-c-3", "353-c-4", "353-c-5", "353-c-6",
"382-c-1", "390-c-1", "390-c-2", "390-c-3"), class = "factor"),
ToothID = structure(c(3L, 3L, 3L, 8L, 8L, 8L, 7L, 7L, 7L,
7L), .Label = c("LI2", "LM1", "LM1-2", "LM3", "LP1-2", "M2",
"RM1-2", "RM2"), class = "factor"), sex = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("F", "M"), class = "factor"),
Al.Qahtani.category = structure(c(2L, 5L, 8L, 2L, 5L, 8L,
2L, 6L, 7L, 8L), .Label = c("AC", "CR 1/2", "CR 3/4", "CRC",
"R 1/2", "R 1/4", "R 3/4", "RC", "Ri ", "unk"), class = "factor"),
AgeCat_first = structure(c(1L, 2L, 3L, 2L, 3L, 4L, 1L, 2L,
2L, 3L), .Label = c("1", "2", "3", "4", "5"), class = "factor"),
AgeCat_second = c(2L, 3L, 4L, 2L, 3L, 4L, 2L, 3L, 4L, 4L),
sample_age_first = structure(c(9L, 18L, 23L, 17L, 27L, 6L,
10L, 13L, 21L, 23L), .Label = c("10.5 to 16.5", "11.5 to 14.5",
"11.5 to 15.5", "11.5 to 18.5", "11.5 to 19.5", "12.5 to 15.5",
"12.5 to 19.5", "15.5 to 20.5", "1.5 to 2.5", "1.5 to 3.5",
"17.5 to 22.5", "2.5 to 4.5", "3.5 to 6.5", "3.5 to 7.5",
" 4.5 to 6.5 ", "4.5 to 6.5", "4.5 to 7.5", "4.5 to 8.5",
"6.5 to 11.5", "6.5 to 8.5", "6.5 to 9.5", "7.5 to 10.5",
"8.5 to 10.5", "8.5 to 11.5", "8.5 to 12.5", "9.5 to 12.5",
"9.5 to 13.5", "9.5 to 15.5", "unk"), class = "factor"),
sample_age_second = structure(c(16L, 25L, 7L, 15L, 26L, 7L,
15L, 22L, 2L, 7L), .Label = c("10.5 to 16.5", "11.5 to 13.5",
"11.5 to 14.5", "11.5 to 15.5", "11.5 to 18.5", "11.5 to 19.5",
"12.5 to 15.5", "12.5 to 19.5", "14.5 to 17.5", "15.5 to 20.5",
"1.5 to 3.5", "17.5 to 22.5", "3.5 to 6.5", "4.5 to 6.5",
"4.5 to 7.5", "4.5 to7.5", " 5.5 to 6.5 ", "6.5 to 11.5",
"6.5 to 8.5", "6.5 to 9.5", "7.5 to 11.5", "7.5 to 12.5",
"8.5 to 12.5", "9.5 to 12.5", "9.5 to12.5", "9.5 to 13.5",
"9.5 to 15.5", "unk"), class = "factor"), AgeCat_adult = c(9L,
9L, 9L, 8L, 8L, 8L, 7L, 7L, 7L, 7L), age_at_death = structure(c(3L,
3L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("18-30",
"31-45", ">45", "Adolescent", "Ind"), class = "factor"),
weight_percent_.N = c(11.5, 6.6, 6.8, 7.8, 8.7, 9.4, 5.6,
5.6, 9.1, 3.9), weight_percent_C = c(37.8, 26.2, 29.5, 32.7,
34.7, 34.4, 22, 30.7, 46.8, 22.7), juv_deltaN_dentine = c(4.54,
4.45, NA, 4.03, 5.73, 6.81, 5.03, 4.58, 0.3, NA), juv_deltaC_dentine = c(-22.042,
-22.865, -24.345, -23.557, -23.24, -22.282, -22.85, -22.697,
-25.439, -25.776), juv_proxy = c(7.958, 7.135, 5.655, 6.443,
6.76, 7.718, 7.15, 7.303, 4.561, 4.224), Adult_deltaC_collagen = c(-18.62,
-18.62, -18.62, -18.9, -18.9, -18.9, -18.64, -18.64, -18.64,
-18.64), adult_proxy = c(11.38, 11.38, 11.38, 11.1, 11.1,
11.1, 11.36, 11.36, 11.36, 11.36), Adult_deltaC_apatite = c(12.29,
12.29, 12.29, -10.23, -10.23, -10.23, -10.73, -10.73, -10.73,
-10.73), Adult_deltaN = c(-18.62, -18.62, -18.62, -18.9,
-18.9, -18.9, -18.64, -18.64, -18.64, -18.64), apatite_collagen_spacing = c(8.66,
8.66, 8.66, 7.67, 7.67, 7.67, 7.74, 7.74, 7.74, 7.74), Adult_percent_C = structure(c(2L,
2L, 2L, 6L, 6L, 6L, 7L, 7L, 7L, 7L), .Label = c("14.31%",
"22.35%", "33.96%", "34.58%", "36.60%", "39.07%", "39.51%",
"42.12%", "42.17%", "42.29%", "42.81%", "44.01%", "44.72%",
"45.52%"), class = "factor"), Adult_percent_N = structure(c(14L,
14L, 14L, 4L, 4L, 4L, 5L, 5L, 5L, 5L), .Label = c("12.16%",
"12.30%", "13.04%", "13.78%", "14.20%", "14.89%", "14.97%",
"15.13%", "15.18%", "15.66%", "15.85%", "16.10%", "4.60%",
"7.98%"), class = "factor"), Adult_CN_ratio = c(3.27, 3.27,
3.27, 3.31, 3.31, 3.31, 3.25, 3.25, 3.25, 3.25), delta_18O = c(-5.5,
-5.5, -5.5, -4.79, -4.79, -4.79, -5.39, -5.39, -5.39, -5.39
), CP = c(0.17, 0.17, 0.17, 0.21, 0.21, 0.21, 0.2, 0.2, 0.2,
0.2), IR_SF = c(3.33, 3.33, 3.33, 3.12, 3.12, 3.12, 3.19,
3.19, 3.19, 3.19), adult_bone_sampled = structure(c(2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("femur", "humerus",
"occipital", "temporal", "tibia"), class = "factor")), .Names = c("Number",
"ToothID", "sex", "Al.Qahtani.category", "AgeCat_first", "AgeCat_second",
"sample_age_first", "sample_age_second", "AgeCat_adult", "age_at_death",
"weight_percent_.N", "weight_percent_C", "juv_deltaN_dentine",
"juv_deltaC_dentine", "juv_proxy", "Adult_deltaC_collagen", "adult_proxy",
"Adult_deltaC_apatite", "Adult_deltaN", "apatite_collagen_spacing",
"Adult_percent_C", "Adult_percent_N", "Adult_CN_ratio", "delta_18O",
"CP", "IR_SF", "adult_bone_sampled"), row.names = c(NA, 10L), class = "data.frame")