我正在尝试使用外部函数(sii
包)来汇总大量数据。
我需要做的是在每个展示级别上针对每个主题,每个系统计算SII。
示例数据:
data <- structure(list(Subject = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L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2L, 2L,
3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L), .Label = c("55", "65", "75"
), class = "factor"), Frequency = c(125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 315, 315, 315, 315, 315,
315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
315, 315, 315, 315, 315, 315, 315, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 630, 630, 630, 630, 630,
630, 630, 630, 630, 630, 630, 630, 630, 630, 630, 630, 630,
630, 630, 630, 630, 630, 630, 630, 800, 800, 800, 800, 800,
800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800,
800, 800, 800, 800, 800, 800, 800, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250,
1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250,
1250, 1250, 1250, 1250, 1600, 1600, 1600, 1600, 1600, 1600,
1600, 1600, 1600, 1600, 1600, 1600, 1600, 1600, 1600, 1600,
1600, 1600, 1600, 1600, 1600, 1600, 1600, 1600, 2000, 2000,
2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000,
2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000,
2000, 2000, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500,
2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500,
2500, 2500, 2500, 2500, 2500, 2500, 3000, 3000, 3000, 3000,
3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000,
3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000, 3000,
3150, 3150, 3150, 3150, 3150, 3150, 3150, 3150, 3150, 3150,
3150, 3150, 3150, 3150, 3150, 3150, 3150, 3150, 3150, 3150,
3150, 3150, 3150, 3150, 4000, 4000, 4000, 4000, 4000, 4000,
4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000,
4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 5000, 5000,
5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
5000, 5000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000,
6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000,
6000, 6000, 6000, 6000, 6000, 6000, 6300, 6300, 6300, 6300,
6300, 6300, 6300, 6300, 6300, 6300, 6300, 6300, 6300, 6300,
6300, 6300, 6300, 6300, 6300, 6300, 6300, 6300, 6300, 6300,
8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000,
8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000,
8000, 8000, 8000, 8000), REM_SPL = c(43.68, 38.85, 51.43,
48.71, 59.22, 58.62, 38.51, 38.45, 48.33, 48.44, 58.18, 58.34,
52.51, 39.6, 58.89, 49.06, 64.63, 58.7, 40.42, 38.81, 49.03,
48.52, 58.3, 58.31, 54.92, 49.44, 62.59, 59.24, 70.32, 68.97,
48.43, 48.19, 58.21, 58.16, 68.17, 67.99, 63.83, 51.47, 68.49,
59.93, 73.25, 69.09, 48.69, 48.3, 58.35, 58.1, 68.19, 68.01,
60.9, 50.42, 68.57, 61.23, 76.59, 71.69, 53.6, 52.7, 63.7,
62.63, 73.63, 72.59, 69.31, 50.73, 73.51, 60.53, 78.59, 71.52,
52.12, 51.55, 62.76, 61.94, 73.15, 72.33, 60.74, 57.26, 68.37,
66.47, 76.5, 75.78, 52.44, 49.21, 62.49, 58.96, 72.44, 69.11,
68.65, 60.55, 72.73, 67.42, 78.12, 75.97, 50.62, 58.85, 58.9,
61.92, 70.33, 68.8, 55.39, 50.46, 62.96, 59.28, 71.08, 68.47,
48.88, 61.78, 58.9, 71.68, 68.8, 80.89, 64.34, 56.79, 68.32,
61.46, 73.3, 68.84, 62.02, 68.72, 68.09, 74.56, 73.49, 80.8,
56.69, 59.3, 64.04, 67.76, 72.05, 76.68, 51.93, 69.98, 61.96,
79.52, 71.84, 88.99, 67, 65.08, 70.76, 70.07, 75.18, 77.28,
71.03, 77.65, 75.63, 82.24, 79.81, 88.9, 51.92, 57.93, 59.21,
66.1, 67.46, 75.01, 56.59, 68.41, 65.69, 77.82, 75.5, 87.89,
63.7, 64.53, 67.67, 69.39, 71.81, 76.13, 69.27, 76.85, 73.64,
81.51, 78.2, 87.85, 48.87, 53.9, 55.78, 61.65, 63.82, 70.4,
58.82, 65.38, 67.34, 74.02, 76.93, 83.84, 61.42, 61.24, 65.35,
65.97, 69.53, 72.23, 68.71, 74.23, 73.86, 79.7, 79.37, 85.62,
48.01, 50.44, 54.41, 57.41, 61.56, 65.25, 55.58, 60.89, 63.1,
68.84, 71.74, 77.46, 60.05, 58.6, 63.73, 62.9, 67.59, 68.1,
66.15, 68.8, 70.82, 74.09, 76.38, 79.82, 47.18, 48.5, 53.45,
55.01, 60.08, 61.96, 50.95, 55.74, 57.98, 63.25, 65.43, 71.02,
59.17, 56.77, 63.17, 61.08, 67.06, 65.64, 62.25, 64.22, 66.68,
69.38, 71.26, 74.48, 45.35, 46.41, 51.51, 52.74, 57.89, 59.15,
49.19, 51.76, 55.54, 58.63, 61.76, 65.99, 57.58, 54.92, 61.84,
59.05, 65.64, 63.46, 61.35, 60.78, 64.83, 65.47, 68.72, 69.57,
46.65, 47.33, 51.94, 53.13, 57.31, 59, 49.36, 51.67, 55.5,
57.69, 60.82, 63.09, 60.43, 56.86, 64.43, 60.78, 68.14, 64.65,
64.16, 60.72, 66.77, 64.85, 70.22, 68.47, 52.05, 52.4, 57.11,
57.74, 62.04, 63.19, 54.05, 54.49, 58.79, 59.71, 62.52, 63.23,
66.43, 61.57, 70.32, 65.49, 73.94, 69.19, 68.14, 62.49, 70.3,
66.13, 72.44, 68.77, 58.81, 58.52, 63.77, 63.85, 68.05, 68.88,
60.06, 60.46, 64.5, 64.38, 67.55, 67.18, 70.69, 66.81, 74.87,
70.92, 78.38, 74.41, 72.09, 66.25, 74.33, 69.39, 76.22, 71.49,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 60.18, 59.65, 64.79,
64.88, 68.88, 70.03, 67.33, 66.6, 71.46, 71.19, 73.76, 73.17,
69.65, 67.08, 73.98, 71.05, 77.77, 74.67, 75.44, 69.74, 78.49,
73.39, 79.65, 75.22, 58.4, 59.01, 63.43, 64.86, 67.39, 69.91,
68.71, 66.86, 73.05, 75.1, 74.7, 76.83, 65.9, 65.64, 71.34,
70.31, 75.86, 73.99, 71.73, 67.53, 77.7, 75.64, 78.59, 77.33,
58.44, 58.86, 63.4, 64.32, 67.55, 69.36, 66.91, 66.78, 71.71,
75.09, 73.4, 76.7, 66.48, 64.59, 71.47, 68.87, 75.38, 72.33,
68.31, 66.76, 75.47, 75.42, 76.96, 76.82, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 55.72, 55.8, 60.74, 61.53, 65.31, 66.82,
67.76, 66.76, 71.6, 72.51, 73.49, 74.22, 63.62, 62.1, 68.72,
66.45, 72.44, 69.93, 68.97, 67.19, 75.25, 73, 76.63, 74.49,
52.18, 51.25, 57.97, 57.54, 62.94, 63.07, 67.82, 67.65, 71.4,
72, 73.4, 73.92, 60.18, 58.02, 66.23, 63.48, 70.87, 67.6,
68.92, 68.42, 75.79, 72.7, 77.23, 74.33), Thresh_SPL = c(40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 65, 60, 65, 60,
65, 60, 65, 60, 65, 60, 65, 60, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 33, 33, 33, 33,
33, 33, 33, 33, 33, 33, 33, 33, 58, 53, 58, 53, 58, 53, 58,
53, 58, 53, 58, 53, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 34.6, 34.6, 34.6, 34.6, 34.6,
34.6, 34.6, 34.6, 34.6, 34.6, 34.6, 34.6, 59.6, 54.6, 59.6,
54.6, 59.6, 54.6, 59.6, 54.6, 59.6, 54.6, 59.6, 54.6, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 35, 30, 35, 30, 35, 30, 35, 30, 35, 30, 35, 30, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 44.6,
44.6, 44.6, 44.6, 44.6, 44.6, 44.6, 44.6, 44.6, 44.6, 44.6,
44.6, 69.6, 59.6, 69.6, 59.6, 69.6, 59.6, 69.6, 59.6, 69.6,
59.6, 69.6, 59.6, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 72.5,
77.5, 72.5, 77.5, 72.5, 77.5, 72.5, 77.5, 72.5, 77.5, 72.5,
77.5, 87.5, 77.5, 87.5, 77.5, 87.5, 77.5, 87.5, 77.5, 87.5,
77.5, 87.5, 77.5, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 76.5,
81.5, 76.5, 81.5, 76.5, 81.5, 76.5, 81.5, 76.5, 81.5, 76.5,
81.5, 96.5, 81.5, 96.5, 81.5, 96.5, 81.5, 96.5, 81.5, 96.5,
81.5, 96.5, 81.5, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 77.5,
82.5, 77.5, 82.5, 77.5, 82.5, 77.5, 82.5, 77.5, 82.5, 77.5,
82.5, 82.5, 77.5, 82.5, 77.5, 82.5, 77.5, 82.5, 77.5, 82.5,
77.5, 82.5, 77.5, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 94,
104, 94, 104, 94, 104, 94, 104, 94, 104, 94, 104, 104, 89,
104, 89, 104, 89, 104, 89, 104, 89, 104, 89)), row.names = c(NA,
-504L), class = "data.frame")
sii
函数带有几个参数:
sii(speech = speech, threshold = threshold, freq = frequency, method = "one-third octave", interpolate = T)
我想将freq
参数固定为:
freq = c(125,250,500,1000,2000,3150,4000,6300,8000)
一个特别困难的部分是,我需要将speech
和threshold
参数的子集放在Frequency
的稍微不同的值上:
对于speech
:c(125,250,500,1000,2000,3150,4000,6300,8000)
对于threshold
:c(125,250,500,1000,2000,3000,4000,6000,8000)
其他参数需要根据分组进行计算。到目前为止,我没有尝试过:
library(tidyverse)
library(sii)
data %>%
group_by(Subject, Ear, System, Pres_Level) %>%
summarize(SII = sii(speech = . %>%
filter(Frequency %in% c(125, 250, 500, 1000, 2000, 3150, 4000, 6300, 8000)) %>%
pull(REM_SPL),
threshold = . %>%
filter(Frequency %in% c(125, 250, 500, 1000, 2000, 3000, 4000, 6000, 8000)) %>%
pull(Thresh_SPL),
freq = frequency, method = "one-third octave", interpolate = T))
Error in sii(speech = . %>% filter(Frequency %in% c(125, 250, 500, 1000, :
`speech' must have the same length as `freq'.
尝试维护参数分组:
data %>%
select(-REM_Level) %>%
filter(Frequency >= 125, Frequency <= 8000) %>%
group_by(Subject, Ear, System, Pres_Level) %>%
mutate(Speech = tibble(REM_SPL) %>%
filter(Frequency %in% c(125, 250, 500, 1000, 2000, 3150, 4000, 6300, 8000))) %>%
pull(REM_SPL)),
threshold = tibble(Thresh_SPL) %>%
filter(Frequency %in% c(125, 250, 500, 1000, 2000, 3000, 4000, 6000, 8000) %>%
pull(Thresh_SPL))) %>%
mutate(SII = sii(speech = speech, threshold = threshold, freq = c(125, 250, 500, 1000, 2000, 3000, 4000, 6000, 8000),
method = "one-third octave", interpolate = T))
Error in mutate_impl(.data, dots) :
Column `Speech` is of unsupported class data.frame
我曾尝试使用一些嵌套循环,但这根本没有用。
我想要的输出是这样的(这些是伪造的SII值):
Subject System Pres_Level SII
1 1 A 55 0.65
2 1 B 55 0.60
3 1 C 55 0.60
4 1 A 65 0.70
5 1 B 65 0.75
6 1 C 65 0.80
7 1 A 75 0.76
8 1 B 75 0.78
9 1 C 75 0.74
10 2 A 55 0.55
11 2 B 55 0.58
12 2 C 55 0.57
13 2 A 65 0.74
14 2 B 65 0.72
15 2 C 65 0.82
16 2 A 75 0.80
17 2 B 75 0.82
18 2 C 75 0.76
19 3 A 55 0.58
20 3 B 55 0.62
21 3 C 55 0.64
22 3 A 65 0.74
23 3 B 65 0.76
24 3 C 65 0.78
25 3 A 75 0.80
26 3 B 75 0.76
27 3 C 75 0.74
有人可以建议我如何实现我想要的吗?
答案 0 :(得分:1)
我相信这就是您要寻找的东西。您需要注意的一件事是git clone git@github.com:bigbugboy/hello-world-again.git
返回的内容(长度为10的对象,而不是向量长度为1的对象)。您需要从结果中进一步提取SII值,因此在sii
调用中为sii(...)$sii
。
用新数据编辑后:
summarize