У меня возникли проблемы с разделением частей моего набора данных на основе нечисловых переменных. У меня такой вопрос: как мне выбрать часть переменных из набора данных, которые не связаны с числами?
Это данные, с которыми я работаю:
structure(list
(Ferret.ID = c(558L, 558L, 558L, 558L, 558L, 558L,
558L, 558L, 558L, 558L, 558L, 558L, 558L, 558L, 558L, 558L, 560L,
560L, 560L, 560L, 560L, 560L, 560L, 560L, 560L, 560L, 560L, 560L,
560L, 560L, 560L, 560L, 561L, 561L, 561L, 561L, 561L, 561L, 561L,
561L, 561L, 561L, 561L, 561L, 561L, 561L, 561L, 561L, 562L, 562L,
562L, 562L, 562L, 562L, 562L, 562L, 562L, 562L, 562L, 562L, 562L,
562L, 562L, 562L, 563L, 563L, 563L, 563L, 563L, 563L, 563L, 563L,
563L, 563L, 563L, 563L, 563L, 563L, 563L, 563L, 564L, 564L, 564L,
564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L, 564L,
564L, 564L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L, 565L,
565L, 565L, 565L, 565L, 565L, 565L, 565L, 574L, 574L, 574L, 574L,
574L, 574L, 574L, 574L, 574L, 574L, 574L, 574L, 574L, 574L, 574L,
574L, 542L, 542L, 542L, 542L, 542L, 542L, 542L, 542L, 542L, 542L,
542L, 542L, 542L, 542L, 542L, 542L, 543L, 543L, 543L, 543L, 543L,
543L, 543L, 543L, 543L, 543L, 543L, 543L, 543L, 543L, 543L, 543L,
544L, 544L, 544L, 544L, 544L, 544L, 544L, 544L, 544L, 544L, 544L,
544L, 544L, 544L, 544L, 544L, 545L, 545L, 545L, 545L, 545L, 545L,
545L, 545L, 545L, 545L, 545L, 545L, 545L, 545L, 545L, 545L, 546L,
546L, 546L, 546L, 546L, 546L, 546L, 546L, 546L, 546L, 546L, 546L,
546L, 546L, 546L, 546L, 547L, 547L, 547L, 547L, 547L, 547L, 547L,
547L, 547L, 547L, 547L, 547L, 547L, 547L, 547L, 547L, 548L, 548L,
548L, 548L, 548L, 548L, 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L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("None",
"Vaccine"), class = "factor"),
Day = c(-2L, -1L, 0L, 1L, 2L,
3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L,
0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L,
-2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L,
31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L,
27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L,
20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L, 0L, 1L, 2L,
3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L,
0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L,
-2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L,
31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L,
27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L,
20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L, 0L, 1L, 2L,
3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, -2L, -1L,
0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L, 31L, 32L,
-2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L, 29L, 30L,
31L, 32L, -2L, -1L, 0L, 1L, 2L, 3L, 7L, 14L, 20L, 26L, 27L, 28L,
29L, 30L, 31L, 32L),
Temperature = c(100.6, 101.5, 101.9, 101.2,
101.8, 101.9, 101.8, 102.1, 102, 100.6, 100.7, 101.7, 101.6,
103.5, 103.1, 100.6, 102.3, 102, 100.1, 101.7, 102.2, 101.8,
100.7, 101.2, 101.7, 100.8, 100.4, 100.7, 101, 104.6, 101.5,
100.8, 102.5, 102.7, 100.8, 100.5, 102.1, 102.4, 101.5, 102.1,
102.1, 100.2, 100.5, 100.9, 102, 104.4, 102.2, 99.8, 101.3, 101.5,
101.9, 102.5, 102.1, 101.8, 101.6, 101.9, 102.6, 100.6, 101.4,
100.5, 101.8, 104.7, 103.1, 100.6, 103.2, 103.7, 102.5, 102.7,
101.5, 102.4, 102, 100.9, 101.8, 100.2, 102.8, 100.8, 102.8,
105.1, 103.3, 101.2, 102, 102.2, 101.5, 102.3, 102, 101.4, 100.6,
101.6, 101.3, 101.7, 102, 101.6, 101.6, 103.2, 103.4, 100.7,
102, 102.3, 102.3, 100.5, 103, 102.8, 102.9, 101.5, 102.4, 102.4,
101.2, 102, 102.1, 104, 102.1, 101.5, 102.5, 102.2, 101.9, 102.7,
102.5, 102.7, 102.2, 102.2, 102.1, 101.6, 101, 102.4, 102, 104.5,
103.1, 101.2, 100.1, 100.7, 100.5, 100.4, 101.8, 100.9, 100.6,
101.1, 101.5, 100.2, 100.1, 101.5, 101.9, 102.7, 102.3, 99.4,
100.7, 101.1, 100.5, 101.6, 102.4, 102, 99.5, 102.3, 102.8, 100.4,
101.3, 100.9, 101.8, 103.2, 101.9, 102.3, 102.6, 102.2, 101,
101.5, 102.2, 101.7, 101.3, 101.3, 103.2, 100.8, 100, 101.5,
101.6, 103.3, 102.7, 101.8, 100.5, 101.1, 101.6, 101.6, 102.3,
102.2, 101.4, 100.9, 102.1, 100.5, 100.5, 100.7, 102.5, 103,
102.1, 99.8, 101.4, 101.7, 101.6, 102.7, 102.8, 102.4, 102.2,
102.8, 102.9, 103, 101.4, 102.1, 102, 104.2, 103.2, 102, 102.6,
102.5, 100.2, 101, 101.8, 101.4, 100.2, 100.8, 101.9, 101.3,
102.2, 101, 101, 101.6, 101.5, 100.8, 100.7, 101.2, 101.6, 101.5,
101.9, 101.6, 101.7, 102.2, 100.8, 100, 101, 101.7, 101, 103.3,
101.1, 101.7, 101.2, 101.6, 100.4, 101.6, 102, 101.6, 101.5,
101.8, 101.7, 101.9, 102.2, 101.3, 102.3, 101.4, 101.8, 101.4),
Weight = c(1420L, 1420L, 1390L, 1380L, 1400L, 1390L, 1400L,
1400L, 1450L, 1440L, 1420L, 1420L, 1410L, 1390L, 1350L, 1240L,
1060L, 1060L, 1070L, 1060L, 1050L, 1060L, 1020L, 1070L, 1110L,
1150L, 1130L, 1130L, 1110L, 1090L, 1050L, 1000L, 1050L, 1040L,
1050L, 1050L, 1050L, 1050L, 1040L, 1020L, 1040L, 1100L, 1100L,
1120L, 1080L, 990L, 1020L, 990L, 1100L, 1100L, 1090L, 1110L,
1100L, 1100L, 1080L, 1080L, 1090L, 1130L, 1110L, 1100L, 1090L,
1080L, 1030L, 990L, 1500L, 1440L, 1400L, 1410L, 1420L, 1410L,
1370L, 1410L, 1420L, 1450L, 1400L, 1440L, 1420L, 1380L, 1360L,
1360L, 1100L, 1100L, 1110L, 1110L, 1110L, 1110L, 1080L, 1110L,
1120L, 1150L, 1140L, 1130L, 1130L, 1120L, 1110L, 1080L, 1050L,
1060L, 1060L, 1050L, 1060L, 1060L, 1040L, 1060L, 1060L, 1060L,
1080L, 1080L, 1070L, 1040L, 1020L, 1040L, 1140L, 1150L, 1160L,
1170L, 1180L, 1170L, 1130L, 1180L, 1170L, 1200L, 1190L, 1200L,
1200L, 1150L, 1120L, 1090L, 1180L, 1180L, 1160L, 1170L, 1170L,
1180L, 1240L, 1230L, 1230L, 1230L, 1230L, 1250L, 1240L, 1240L,
1230L, 1210L, 1230L, 1250L, 1240L, 1260L, 1270L, 1270L, 1280L,
1280L, 1290L, 1270L, 1260L, 1270L, 1260L, 1230L, 1260L, 1290L,
1000L, 1030L, 990L, 1010L, 1000L, 1000L, 990L, 1000L, 980L, 980L,
980L, 960L, 950L, 930L, 930L, 930L, 1200L, 1210L, 1180L, 1200L,
1200L, 1220L, 1230L, 1230L, 1250L, 1250L, 1220L, 1230L, 1220L,
1210L, 1230L, 1220L, 1500L, 1060L, 1070L, 1090L, 1100L, 1100L,
1110L, 1130L, 1130L, 1130L, 1120L, 1110L, 1199L, 1090L, 1100L,
1110L, 1080L, 1080L, 1070L, 1100L, 1100L, 1100L, 1130L, 1140L,
1090L, 1120L, 1110L, 1110L, 1110L, 1080L, 1080L, 1100L, 1290L,
1300L, 1320L, 1031L, 1310L, 1300L, 1300L, 1280L, 1270L, 1230L,
1250L, 1250L, 1220L, 1080L, 1200L, 1200L, 890L, 870L, 860L, 820L,
800L, 800L, 850L, 850L, 830L, 830L, 800L, 800L, 800L, 820L, 820L,
820L)), class = "data.frame", row.names = c(NA, -256L))
Я пытаюсь найти среднюю температуру вакцинированных и невакцинированных («Нет») хорьков. Однако я не могу найти способ разделить данные на основе логического фактора, такого как «Вакцинирован» и «Не вакцинирован». Как мне это сделать? Я пробовал что-то подобное, но не работает:
mean(subset(Ferrets, Ferrets$Vaccine="Vaccine",
select = c('Vaccine', 'Day', 'Temperature')))