我一直在空间中进行360点实验,实验包括在3种不同条件下测量10次响应。因此,数据以10 800 x 3 data.frame排列(列为Position,Condition,Response)。我想进行一次Bartlett测试来证明在每一点上,无论选择哪种条件,反应都是同步的。为了执行此操作,我使用循环为每个点生成Bartlett Test p.value,如下所示
npoints <- length(point_list)
bart.results <- numeric(npoints)
for (i in point_list)
bart.results[i] <- bartlett.test(Response ~ Condition, data = test_data %>%
filter(Position == i))$p.value
但我一直有同样的错误:
Error in bartlett.test.default(c(2.6605504587156, 2.6605504587156, 2.6605504587156, :there must be at least 2 observations in each group
,考虑到每个条件,我有10个回复的副本,我不明白我做错了什么
有人可以帮忙吗?
位置102的数据示例dput
:
structure(list(x = c(-0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542,
-0.542, -0.542, -0.542, -0.542, -0.542, -0.542, -0.542), y = c(-0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332, -0.332,
-0.332, -0.332, -0.332), z = c(0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3), Corriente = c(2.495, 2.495, 2.495, 2.495, 2.495, 2.495,
2.495, 2.495, 2.495, 2.495, 2.497, 2.497, 2.497, 2.497, 2.497,
2.497, 2.497, 2.497, 2.497, 2.497, 3.98, 3.98, 3.98, 3.98, 3.98,
3.98, 3.98, 3.98, 3.98, 3.98, 3.995, 3.995, 3.995, 3.995, 3.995,
3.995, 3.995, 3.995, 3.995, 3.995, 5.49, 5.49, 5.49, 5.49, 5.49,
5.49, 5.49, 5.49, 5.49, 5.49, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5), Bx = c(2.11009174311927, 2.20183486238532, 2.29357798165138,
2.29357798165138, 2.29357798165138, 2.20183486238532, 2.38532110091743,
2.47706422018349, 2.38532110091743, 2.20183486238532, 2.6605504587156,
2.56880733944954, 2.75229357798165, 2.6605504587156, 2.56880733944954,
2.56880733944954, 2.75229357798165, 2.6605504587156, 2.6605504587156,
2.47706422018349, 2.56880733944954, 2.47706422018349, 2.6605504587156,
2.56880733944954, 2.56880733944954, 2.6605504587156, 2.6605504587156,
2.75229357798165, 2.6605504587156, 2.56880733944954, 3.85321100917431,
3.76146788990826, 4.03669724770642, 3.85321100917431, 3.85321100917431,
3.85321100917431, 3.94495412844037, 4.03669724770642, 3.85321100917431,
3.76146788990826, 5.13761467889908, 5.22935779816514, 5.5045871559633,
5.41284403669725, 5.32110091743119, 5.32110091743119, 5.13761467889908,
4.58715596330275, 4.67889908256881, 4.4954128440367, 4.77064220183486,
4.67889908256881, 4.95412844036697, 4.86238532110092, 4.77064220183486,
4.77064220183486, 4.86238532110092, 4.95412844036697, 4.95412844036697,
4.58715596330275), By = c(30.4587155963303, 30.2752293577982,
30.3669724770642, 30.3669724770642, 30.4587155963303, 30.8256880733945,
30.7339449541284, 30.8256880733945, 30.3669724770642, 30.0917431192661,
34.5871559633027, 34.4954128440367, 34.5871559633027, 34.5871559633027,
34.4954128440367, 34.6788990825688, 34.6788990825688, 34.6788990825688,
34.4954128440367, 34.4954128440367, 49.0825688073394, 48.8990825688073,
49.0825688073394, 49.4495412844037, 49.4495412844037, 49.4495412844037,
49.1743119266055, 49.2660550458716, 49.1743119266055, 49.0825688073394,
55.5963302752294, 55.5963302752294, 55.5963302752294, 55.6880733944954,
55.5963302752294, 56.0550458715596, 55.9633027522936, 55.7798165137615,
55.4128440366973, 55.2293577981651, 76.1467889908257, 76.3302752293578,
76.605504587156, 76.605504587156, 76.4220183486239, 76.605504587156,
76.605504587156, 76.8807339449541, 76.697247706422, 76.5137614678899,
67.2477064220184, 67.1559633027523, 67.2477064220184, 67.1559633027523,
67.1559633027523, 67.5229357798165, 67.3394495412844, 67.5229357798165,
66.9724770642202, 66.7889908256881), Bz = c(-0.825688073394495,
-0.642201834862385, -0.825688073394495, -0.73394495412844, -1.19266055045872,
-1.46788990825688, -1.37614678899083, -1.28440366972477, -0.73394495412844,
-0.36697247706422, -1.8348623853211, -1.92660550458716, -1.74311926605505,
-1.74311926605505, -1.92660550458716, -1.92660550458716, -2.01834862385321,
-2.20183486238532, -1.55963302752294, -1.65137614678899, -0.73394495412844,
-0.642201834862385, -0.642201834862385, -1.19266055045872, -0.917431192660551,
-1.19266055045872, -0.917431192660551, -1.10091743119266, -1.00917431192661,
-0.55045871559633, -2.93577981651376, -3.02752293577982, -2.84403669724771,
-3.11926605504587, -3.39449541284404, -3.57798165137615, -3.30275229357798,
-3.30275229357798, -2.75229357798165, -2.75229357798165, -4.03669724770642,
-4.31192660550459, -4.03669724770642, -3.85321100917431, -4.12844036697248,
-4.67889908256881, -4.4954128440367, -4.12844036697248, -2.6605504587156,
-2.20183486238532, -2.56880733944954, -2.47706422018349, -2.47706422018349,
-2.56880733944954, -2.6605504587156, -3.11926605504587, -2.84403669724771,
-2.75229357798165, -2.38532110091743, -2.11009174311927), B = c(30.5428813921846,
30.3619830153631, 30.4646562129829, 30.462307735567, 30.5682236141499,
30.939066287498, 30.8570722717294, 30.9517137673495, 30.4693526247761,
30.174422107408, 34.7378267360851, 34.6445390674785, 34.740249601074,
34.733101663239, 34.6445390674785, 34.827239647961, 34.8464473466923,
34.8504325236227, 34.6329971444061, 34.6236392889256, 49.1552235990247,
48.9659937754627, 49.1588192765783, 49.5305798832779, 49.5247169035666,
49.5354226909384, 49.2547780645871, 49.3551549375802, 49.2565723024889,
49.1528263345252, 55.8069706961832, 55.8056133008667, 55.8151897737284,
55.9083050556363, 55.8329810619263, 56.3011310316361, 56.1993068527816,
56.023129399305, 55.6147969452011, 55.4256774737482, 76.4265888475458,
76.6306062263767, 76.9090289724166, 76.8931040386562, 76.7182052925806,
76.9324999246166, 76.9090836915897, 77.1280316850504, 76.8858792699186,
76.6773272054047, 67.4656343421383, 67.3643180838075, 67.4754270440472,
67.3807462802148, 67.3777482770233, 67.7630851132482, 67.5746461349916,
67.7603524553133, 67.1978111955712, 66.979577353921), Position = c(102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102)), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -60L), .Names = c("x", "y",
"z", "Corriente", "Bx", "By", "Bz", "B", "Position"))
响应将是Bx,条件将是&#34; Corriente&#34;