我想以这样一种方式对频率进行分箱,使每个分箱包含大致相同的数量。到目前为止,我设法通过平均划分范围来划分频率,但我还没有找到一种自动计算 bin 大小的方法。
数据:
> dput(sumsq)
structure(list(difftim = c(-170L, -17L, 71L, -487L, -301L, -107L,
-202L, -71L, 404L, 99L, -252L, -18L, 253L, -505L, 421L, 597L,
-454L, 420L, 66L, -202L, 84L, -657L, 0L, -253L, -35L, 21L, -101L,
-152L, -33L, 150L, -253L, -185L, -137L, -100L, -370L, -67L, -218L,
-68L, -71L, 1332L, -151L, -67L, 438L, 34L, 201L, -35L, -83L,
-17L, 269L, -380L, -336L, -125L, 67L, -59L, 170L, 130L, 486L,
-118L, -16L, -33L, -73L, -50L, -404L, 302L, -51L, 302L, 17L,
-17L, 18L, -28L, 388L, 337L, 405L, -34L, -152L, 386L, 152L, 119L,
51L, -17L, 138L, 269L, 219L, 17L, -50L, 302L, 137L, 101L, 49L,
33L, 152L, -34L, 1186L, -33L, 57L, 69L, -338L, 251L, -18L, 67L,
-54L, -437L, 134L, -336L, 322L, -118L, 17L, -824L, 118L, 438L,
1L, 84L, 135L, 52L, -118L, 50L, 87L, -185L, 90L, 73L, -136L,
16L, -37L, -135L, -117L, 235L, 303L, -286L, 286L, 50L, -521L,
151L, 420L, -87L, -184L, -67L, -168L, -33L, -135L, -118L, 1379L,
256L, -34L, -84L, -17L, 135L, 254L, 811L, 168L, 403L, -443L,
-253L, 152L, -185L, -16L, 601L, -825L, -220L, -51L, -219L, 488L,
-51L, 19L, -365L, -249L, 274L, -503L, 37L, 14L, -84L, -320L,
-201L, 118L, 85L, -270L, -121L, 152L, -25L, 17L, -18L, -203L,
-33L, -236L, -371L, 252L, -438L, 219L, 1852L, 3082L, 1026L, -51L,
201L, 371L, 140L, 50L, -499L, 433L, -350L, 57L, -472L, 17L, 185L,
-51L, -118L, 174L, -49L, 185L, -118L, -185L, -337L, -121L, 166L,
-50L, -83L, 250L, 83L, -149L, 83L, -555L, -51L, -100L, -102L,
148L, 116L, 382L, -100L, -174L, 84L, 657L, -232L, -17L, -100L,
-68L, -34L, 135L, 84L, 236L, 153L, -252L, 0L, -169L, 51L, 168L,
163L, 135L, -51L, -303L, -202L, 33L, 101L, -219L, -34L, 51L,
168L, 179L, 404L, 135L, 67L, -233L, 371L, -202L, -112L, -319L,
16L, 115L, -220L, -370L, 682L, -236L, 504L, 8L, -151L, 34L, -45L,
-283L, -69L, 167L, -82L, -102L, -51L, -202L, 534L, -17L, 39L,
55L, 79L, 55L, -35L, -902L, -124L, -1L, -101L, 25L, 214L, 459L,
-367L, -186L, -104L, 50L, 261L, -474L, -168L, 16L, 17L, -209L,
-556L, -236L, -17L, -235L, -67L, -17L, -49L, 504L, -319L, 1702L,
286L, 538L, 657L, 66L, -50L, 269L, 151L, -434L, -404L, -725L,
68L, -572L, -86L, -455L, -236L, -421L, -152L, -370L, 135L, 118L,
-169L, -269L, -286L, -118L, -539L, -68L, -20L, -121L, 785L, -169L,
400L, -253L, -1L, 0L, 84L, -126L, -151L, -50L, -101L, -151L,
-163L, -50L, 0L, -100L, -169L, 497L, -34L, 170L, 154L, -505L,
-338L, -330L, 67L, 306L, -51L, -16L, -17L, 118L, -270L, -168L,
-85L, 977L, 1127L, 34L, -166L, -489L, 0L, -404L, -84L, -455L,
286L, -51L, -403L, 454L, -387L, 371L, -50L, -202L, -219L, -34L,
84L, -303L, 28L, 33L, -10L, -370L, 35L, -151L, 59L, 214L, -101L,
0L, 185L, 252L, 67L, -67L, 362L, -50L, 151L, -16L, -151L, -150L,
50L, -1227L, -320L, -112L, -60L, 85L, 135L, 99L, 20L, -807L,
-50L, 925L, 1177L, -15L, -67L, 2606L, 17L, 539L, 34L, -34L, 34L,
606L, 101L, -85L, -50L, 17L, 444L, -199L, 142L, -17L, -16L, -504L,
134L, -617L, 235L, 202L, -101L, -554L, -17L, -303L, 17L, -118L,
-185L, 0L, -67L, -50L, -118L, 590L, -537L, -80L, -119L, -286L,
354L, -488L, -235L, -336L, -101L, -185L, 169L, -370L, 218L, -101L,
16L, 336L, 0L, 387L, 168L, 219L, 118L, 202L, 236L, -185L, -134L,
-874L, -50L, 118L, 17L, 218L, -67L, 51L, -101L, 34L, 34L, -100L,
16L, 67L, 0L, 0L, -152L, 151L, 51L, 67L, -185L, -337L, 68L, 118L,
84L, 101L, -167L, -404L, 403L, -387L, -127L, 202L, -214L, 84L,
-1L, 33L, 269L, 0L, 112L, 101L, -33L, 50L, -219L, 17L, 17L, -253L,
252L, 51L, 51L, 252L, -17L, -134L, 153L, 135L, 151L, 40L, 294L,
-67L, -61L, -118L, 38L, 0L, -50L, 152L, -218L, -168L, 67L, -67L,
68L, 39L, -1L, 134L, -168L, -135L, 17L, -82L, -17L, 16L, 135L,
51L, 134L, -101L, 101L, 152L, 16L, 118L, 100L, 202L, 218L, -168L,
269L, -118L, 201L, -403L, -420L, 0L, 0L, -370L, -201L, 67L, 319L,
320L, -67L, -335L, 285L, 269L, 151L, 185L, -204L, -403L, -84L,
-111L, 1L, 369L, -67L, -50L, 150L, 0L, 319L, -168L, 16L, -117L,
-39L, -67L, -202L, 249L, -101L, -331L, -49L, -67L, 285L, -168L,
85L, -17L, 118L, 115L, -102L, -84L, 184L, 33L, -151L, -269L,
-118L, -150L, -50L, 67L, -17L, 180L, -5L, -135L, 154L, -51L,
73L, -117L, -123L, -82L, -83L, 959L, -168L, -19L, 134L, -100L,
-135L, -252L, -16L, 202L, -36L, -18L, -39L, -172L, -84L, -286L,
135L, 32L, -138L, -1429L, -84L, 117L, 51L, 134L, -134L, -134L,
151L, -34L, 0L, 689L, 386L, 134L, 117L, -100L, -17L, -69L, -34L,
118L, 50L, -117L, 286L, 68L, 95L, 98L, 204L, -16L, 17L, -168L,
-135L, 151L, -68L, 200L, 169L, 100L, 375L, -152L, -33L, 1L, 17L,
50L, 0L, -17L, 16L, -119L, 202L, 66L, -17L, 0L, 134L, 33L, 14L,
252L, 67L, 84L, -122L, -84L, -68L, 12L, -1397L, 51L, -101L, -68L,
-17L, 186L, 118L, 33L, 85L, -18L, 16L, 98L, 135L, 0L, -17L, 340L,
-35L, -34L, -34L, 336L, 85L, 101L, -98L, -1L, 251L, 101L, 151L,
-519L, -201L, -68L, -319L, -169L, -421L, -269L, -342L, 236L,
-543L, -1785L, -87L, 100L, 304L, 118L, 0L, -16L, 639L, 101L,
67L, -160L, 276L, 135L, -51L, 85L, 15L, -219L, -336L, 926L, 236L,
-320L, 200L, -33L, -50L, -611L, -353L, -67L, -17L, -160L, 17L,
-269L, -286L, -151L, 135L, 183L, -387L, -101L, -169L, -219L,
17L, -137L, -33L, -101L, -80L, 269L, -17L, 252L, -67L, -66L,
118L, -324L, -100L, -135L, 235L, -17L, 68L, -488L, 387L, 205L,
-117L, -455L, 0L, 455L, -125L, -370L, -34L, 185L, -34L, -1L,
-101L, -123L, -729L, 504L, 0L, 123L, 352L, 218L, 134L, 588L,
537L, -68L, 202L, 135L, 101L, -285L, 23L, -201L, 363L, 65L, 202L,
-211L, 34L, 0L, -134L, -219L, 17L, 420L, 50L, -1L, 319L, -48L,
151L, 17L, 152L, 945L, 46L, -33L, 232L, 16L, 15L, -304L, -168L,
151L, -55L, 51L, 0L, 33L, 50L, -183L, 806L, -422L, -185L, -102L,
-151L, 66L, -148L, 353L, -337L, -14L, 67L, -185L, -17L, -118L,
-134L, 134L, 18L, -168L, 6L, 588L, 235L, -232L, 253L, 67L, -51L,
-151L, -118L, -135L, 212L, -131L, -135L, -18L, 102L, 56L, -100L,
84L, 84L, 150L, 50L, 17L, -35L, 136L, 34L, -147L, -35L, 51L,
-51L, 0L, -118L, 16L, -118L, -67L, -67L, -123L, -84L, 168L, -17L,
-353L, 51L, -84L, 17L, -101L, -17L, 202L, -220L, -1L, -159L,
304L, -792L, -219L, 92L, -185L, 31L, -252L, 572L, -421L, 33L,
1128L, -270L, 0L, 235L, -639L, -54L, 135L, 34L, 236L, -152L,
124L, 33L, -17L, -67L, 202L, 723L, -34L, 82L, 201L, 1L, -169L,
110L, -348L, -11L, 606L, -17L, -394L, -118L, 673L, 35L, 51L,
-842L, 118L, 68L, -13L, -33L, 84L, -67L, -320L, 17L, 168L, -16L,
84L, -268L, -201L, -487L, -68L, 17L, -34L, 336L, -56L, 67L, 101L,
1L, 0L, -101L, 68L, -16L, 16L, -101L, 67L, 33L, 0L, 34L, 51L,
-18L, 52L, 353L, -153L, 117L, -17L, 605L, 252L, 219L, 438L, -31L,
-219L, -101L, 135L, 34L, 51L, 34L, 1497L, -487L, -85L, -137L,
-67L, -135L, -51L, 202L, 51L, -1110L, -67L, -1043L, -308L, -185L,
135L, -202L, -354L, -253L, 84L, -185L, -50L, -354L, 0L, -33L,
7L, -252L, -134L, -284L, 34L, -219L, -219L, -303L, -287L, -135L,
102L, -35L, 860L, -34L, 118L, 68L, -61L, -264L, -168L, 47L, 236L,
-287L, -103L, 17L, -95L, -607L, 438L, -388L, 17L, -287L, -68L,
-253L, 34L, -113L, -101L, 168L, 1885L, 168L, 708L, 135L, 387L,
118L, 556L, 219L, 68L, 51L, 68L, 202L, -370L, -572L, 487L, 0L,
-253L, 405L, 118L, -269L, 741L, -185L, -152L, -84L, -167L, 169L,
102L, 573L, -151L, 235L, 820L, 169L, -186L, 539L, -58L, 4L, 100L,
101L, -573L, -118L, -17L, -34L, -252L, 84L, 1L, 101L, -286L,
269L, 270L, 370L, -168L, 152L, -83L, 34L, -50L, -84L, -51L, 84L,
118L, 51L, 253L, 67L, -117L, 87L, 52L, -319L, -1L, 51L, 149L,
68L, 219L, 589L, -67L, -219L, 689L, 17L, -17L, -219L, -202L,
555L, 806L, -151L, 353L, 673L, -252L, 151L, 438L, 403L, 50L,
-235L, -252L, 84L, -235L, -336L, 182L, 1059L, 84L, -505L, 169L,
134L, -168L, 404L), ratperc = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0, 0, 0, 0, 0, 0, 75.6, 0, 89.6,
24.8, -100, -100, 75.6, 100, 100, -100, -100, -100, -100, -100,
-100, 75.6, 98.4, 98.4, -51.2, -51.2, 0.8, 0.8, 0.4, 0.4, 0.4,
0.4, 75.2, -100, -100, -100, 1.2, -0.4, -0.4, -0.4, -0.4, 100,
100, -1.6, 0, 0, 0, 0, -100, 0.4, 100, 0.4, 0.4, 100, -0.4, -78.4,
0.4, 100, 100, 100, 100, -100, 23.6, 61.2, 61.2, 69.2, 75.6,
75.6, 75.6, 75.6, 75.6, 98, 98, 98, -75.2, -75.2, 47.2, 47.2,
47.2, 47.2, 76.8, 97.6, -71.6, -71.6, -71.6, -71.6, 24, 52, 52,
52, 75.2, 75.2, -77.6, 25.2, 47.2, 76.4, 76.4, 76.4, 76.4, 76.4,
76.4, 76.4, 76.4, 76.4, 76.4, 76.4, 76.4, 76.4, 76.4, -73.2,
-73.2, -73.2, -73.2, 0.8, 0.8, 75.2, 75.2, 75.2, 75.2, 75.2,
75.2, 0.4, 0.4, 0.4, 0.4, 0.4, -100, -100, -100, -100, -100,
73.2, 2, -0.8, -0.8, -0.8, -100, -0.4, -0.4, 50.4, 50.4, 50.4,
50.4, 50.4, 50.4, -76.4, 99.6, 99.6, -76.4, 100, 100, 50.4, 1.2,
28, -1.2, 93.6, 41.2, 1.6, 24.8, -1.6, 0, 0, 24.8, -24, 26, 50.8,
2, 28, 36.4, 24, -43.6, 33.6, 61.2, 81.2, 86.8, 34, -51.6, -2,
28.4, 2, 82, 41.6, 25.6, 82, 0.8, 92, 1.2, 86.4, 54, 96, 0.4,
-54.4, 1.2, -93.2, -49.2, -98.4, -2, -77.2, 93.2, 23.6, 78.8,
42.4, 0.4, 2.8, 70.8, 24.4, 2.4, 62, 92.8, 16.4, -61.2, 24.4,
-77.2, -0.4, 74.8, 3.6, 82, 82, 18, 54, 9.2, 55.2, 96.4, 96.4,
90, 90, -84.4, -84.4, -2.8, -2, -90.4, 2.4, 34.8, 24, -1.6, -16.8,
2.8, 2.4, -83.2, 22.4, 22.4, -1.6, -1.6, 60, -2.4, 2.4, 2, 0.8,
-22.8, 2, -1.6, 25.2, 2, 2, -52.8, -1.2, -1.2, 3.2, -74.4, 3.2,
3.2, -78.4, 0.4, -2.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, -79.2, -0.8,
-0.8, -0.8, -0.8, -0.8, -3.2, 41.2, -0.8, -0.8, -0.8, -0.8, -83.2,
-1.6, -1.6, 0.4, 0.4, 0.4, -90, -1.6, -1.6, -1.6, -1.6, -1.6,
-1.6, -1.6, -1.6, -1.6, -1.6, -1.6, 77.6, -79.6, 80.8, -81.6,
-93.2, -100, 8.4, 75.6, 82.8, 67.2, -27.2, 78.8, 65.6, 84.8,
73.6, 46.8, -62.4, 57.2, 74, 13.6, -0.8, 32.8, -27.2, 6.4, -67.2,
79.2, -64, 58, -40.4, 64, 8, 60, 76.8, -24.8, -52.4, 56.8, 75.6,
38.4, -50.4, -72.8, -83.6, 24, 34.8, 54.4, -54, 67.6, 78.4, -41.6,
-64.4, -83.6, -93.6, 76.8, -2.4, -19.2, -54, -38, 5.2, 52.4,
64.8, 42.4, 77.6, -46.4, -74.8, -60.4, -83.2, -56.4, -34.8, -16.8,
21.2, 40, 59.2, 0.4, -17.6, 24.4, -14.4, 35.2, -26.8, 42, 44,
-1.2, -35.6, 10.8, -19.6, -35.2, 22.4, -18.4, 27.6, -9.6, 43.2,
-31.2, 45.2, 23.6, -16.4, 28.8, 40.4, 25.6, -8, 15.6, 11.2, -17.2,
15.6, -17.6, 18, 24, -9.6, -34.8, 12.4, -17.2, 36.4, -9.2, -35.2,
-19.6, 10.4, -15.6, -30.4, 30.8, 16.4, -14.8, -26.4, -34.4, 52.8,
34.4, 55.6, 21.2, 41.2, 52, 36.8, 50, 15.6, 36, 53.6, -22.8,
14.8, 25.2, -13.2, -18.8, 32, 20.8, -6.8, -16.4, -27.6, 14.4,
26.8, 38, -28.4, 19.6, -23.6, 18.4, -19.6, 11.6, 0, 0, 0, -26,
-52.4, -24.4, 2, 19.6, -10.8, 3.6, 3.6, -25.2, 28.4, 12, -11.2,
3.2, 37.2, 26, 0.8, 47.6, -17.2, 2.4, -12, -52.4, 0.8, 28.4,
-12, 36.4, 2.4, 50.4, -16, 24.4, -2.4, -2.4, 15.2, -1.6, -1.6,
-1.6, 24.4, -36, 33.2, 1.2, 1.2, -48.8, -22.4, -1.2, -100, -1.6,
-1.6, -26.4, 28, -47.6, 86, -1.6, -1.6, -1.6, -1.6, -1.6, 41.6,
-16, 29.6, -14.8, 3.2, 3.2, 100, 0.8, 0.8, 0.8, 0.8, 25.6, 24.8,
-28, 0.8, -39.2, -97.6, -97.6, -50, 0, 0, 49.6, 0.8, 54, 25.6,
-1.2, -1.2, -90.8, 4.4, 4.4, 41.6, -40.8, -6, -6, 51.6, -8.4,
0, 0, 0, -60, 2.8, -52.4, 1.6, 1.6, 1.6, 18.8, 24.4, -0.4, -0.4,
-0.4, -0.4, -51.6, -0.4, -0.4, -0.4, 26, 0, 18, -42.4, -1.6,
-0.4, 60.4, -2.8, -2.8, -2.8, 76, 2.8, 2.8, -29.2, -23.2, 23.6,
-26.8, 0.4, 0.4, -40.8, -3.6, -47.6, 27.6, -2.4, -2.4, -76, -2,
-2, -2, -30.8, 26.8, -4.4, -4.4, -4.4, 3.6, -0.8, -0.8, 67.2,
-1.2, -48.8, 63.2, -42, 50, 30.8, 57.6, -48.8, -48.8, 41.6, -39.2,
-39.2, -35.6, 40, -44, -39.6, -39.6, -50.8, 0, -48.8, 40, -53.2,
52, -47.2, -47.2, -46, 26.4, -29.2, 0, -46.8, -46.8, 34.8, -43.6,
0, 39.2, 0.4, -48.4, 0, -23.6, 29.2, 29.2, -53.2, -53.2, 19.2,
46.4, 46.4, -2, 36, 2, -25.2, -50, -1.6, -2, 35.2, -32.8, 31.2,
-43.2, 46, -28.8, -0.4, -50.4, 0.8, -43.6, 0.4, 27.6, -37.6,
-37.6, 37.6, -50, 40.8, -0.8, -50.4, -49.6, 45.6, 45.6, -48.8,
-0.8, -54, -54, 43.2, -48.8, 46.4, -42.8, 54, -54.4, 34.8, 0.4,
0.4, 0.4, 0.8, -50.4, -50.8, -50.8, 51.6, -68.8, 0.8, 52, -42,
-42, 0, -56.8, -56.8, 0.8, -48, -46.4, -46.8, -46.8, 0.4, 0.4,
37.2, -36.8, -36.8, -0.4, -0.4, -0.4, -0.4, -0.4, -48.8, 0.8,
0.8, 58.8, 2, 2, 2, 2, 29.2, -50.4, 49.6, 41.2, -39.2, 38.8,
-38.8, 28, -38, 40.8, 0.8, 0.8, 0.8, 0.8, 0.8, -51.2, 27.2, -54.8,
0.8, 0.8, -40.4, -40.4, 0, -46.8, 35.2, -50.4, 9.6, -0.4, -15.2,
17.6, -26.8, -14.4, 42.8, 18.8, 2.8, 0, -33.2, -36.4, -7.6, 18.8,
34.4, 8.8, -25.6, -16.8, -10, -50.8, 10, -11.2, -7.2, -15.2,
-62.8, 27.6, -12.8, -1.2, -24.4, 18.8, -7.2, 37.2, 8.4, -40,
-9.6, 20, -27.2, 27.2, 7.2, -31.6, -31.6, 27.6, -1.6, -20, -20,
34.4, 18, -23.6, 28.4, -16, 15.2, -30.4, -9.2, -7.6, 12.4, 23.2,
15.6, 23.2, 37.2, -8.8, -21.6, -31.6, -23.2, 25.2, 33.2, 9.2,
34.4, 18, 5.2, -50.4, 34.8, 12.4, -13.6, -7.2, 6.4, 15.2, 2,
12.8, -14.4, 32.4, 15.6, 23.2, 30, -11.6, -34.8, 12, -24, -11.2,
-41.2, 34.4, 18.8, 18.8, 12, 37.6, 10, 35.2, -24.4, 24.8, 40.4,
52.4, 14, -41.6, 34, 43.2, -6, -28, 24, 35.2, 26.8, -15.2, 28,
38.8, 11.6, 57.6, 28, 12, -18.8, 35.6, 25.2, 40.4, 59.2, -58.4,
10.4, -23.6, 18, -14, 35.2, 13.6, 48.4, 32.8, 32.8, -17.2, -11.2,
26, -24, 15.2, -66.4, 24.4, -30.4, 39.6, 30, 53.2, 59.6, -40.4,
-14, 36, 36, 41.6, 32, 57.6, 8.4, 62, 85.6, 85.6, 84.4, 38, 63.2,
67.2, -42.8, 63.6, 95.2, 65.2, 86.8, 87.2, 9.2, 83.2, 11.6, 83.2,
83.2, 79.6, 63.2, 88.8, -62, -84.8, -84.8, -86.8, -4.4, 87.2,
86, 17.2, 81.6, -60.8, -87.6, 80, 37.2, -64.8, 86.4, 87.2, 94.4,
94, -61.6, 86.8, 86.4, 86.8, 86, -86, 94.4, -87.6, 80, 84.8,
86.8, -64.8, 85.2, 83.2, -90.8, 88.8, 85.6, 85.2, 87.2, 85.2,
85.6, -64, 84.8, 84.4, -90, 84.8, 82, -83.6, 88.4, 92, 80.8,
79.6, 80.4, 78.4, 78.4, 80, 80, 79.2, 81.2, 84.8, -78.4, 80.8,
-88.8, 81.6, 81.6, -64.8, -85.6, 89.2, 90.4, -84, 85.2, -32.8,
49.6, 83.2, 81.2, 79.2, 80, 85.6, 81.6, 34.4, -85.6, 83.6, 82.4,
84, 81.2, 85.6, 85.6, 87.6, 84.8, 85.6, 82.8, -86.4, -60, 36.8,
-85.6, 86.4, -65.6, 81.6, -81.2, 92.8, -86.4, 84.8, 63.2, 36,
86.4, 86.4, 82.4, 83.2, 82.8, 82.4, 80.8, 80.4, 80.4, -63.6,
84.8, 84.8, 68, 93.2, 88, 89.6, 33.6, 83.6, -67.2, 88.8, 88,
85.2, -39.6, 84.8)), .Names = c("difftim", "ratperc"), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L,
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L,
81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L,
94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L,
128L, 129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L,
139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L,
150L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 308L, 309L, 310L,
311L, 312L, 313L, 314L, 315L, 316L, 317L, 318L, 319L, 320L, 321L,
322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 331L, 332L,
333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 341L, 342L, 343L,
344L, 345L, 346L, 347L, 348L, 349L, 350L, 351L, 352L, 353L, 354L,
355L, 356L, 357L, 358L, 359L, 360L, 361L, 362L, 363L, 364L, 365L,
366L, 367L, 368L, 369L, 370L, 371L, 372L, 373L, 374L, 375L, 376L,
377L, 378L, 379L, 380L, 381L, 382L, 383L, 384L, 385L, 386L, 387L,
388L, 389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L,
399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 409L,
410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 419L, 420L,
421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L, 429L, 430L, 431L,
432L, 433L, 434L, 435L, 436L, 437L, 438L, 439L, 440L, 441L, 442L,
443L, 444L, 445L, 446L, 447L, 448L, 449L, 450L, 601L, 602L, 603L,
604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L, 614L,
615L, 616L, 617L, 618L, 619L, 620L, 621L, 622L, 623L, 624L, 625L,
626L, 627L, 628L, 629L, 630L, 631L, 632L, 633L, 634L, 635L, 636L,
637L, 638L, 639L, 640L, 641L, 642L, 643L, 644L, 645L, 646L, 647L,
648L, 649L, 650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L, 658L,
659L, 660L, 661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 669L,
670L, 671L, 672L, 673L, 674L, 675L, 676L, 677L, 678L, 679L, 680L,
681L, 682L, 683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L, 691L,
692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L, 702L,
703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 713L,
714L, 715L, 716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L, 724L,
725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, 733L, 734L, 735L,
736L, 737L, 738L, 739L, 740L, 741L, 742L, 743L, 744L, 745L, 746L,
747L, 748L, 749L, 750L, 901L, 902L, 903L, 904L, 905L, 906L, 907L,
908L, 909L, 910L, 911L, 912L, 913L, 914L, 915L, 916L, 917L, 918L,
919L, 920L, 921L, 922L, 923L, 924L, 925L, 926L, 927L, 928L, 929L,
930L, 931L, 932L, 933L, 934L, 935L, 936L, 937L, 938L, 939L, 940L,
941L, 942L, 943L, 944L, 945L, 946L, 947L, 948L, 949L, 950L, 951L,
952L, 953L, 954L, 955L, 956L, 957L, 958L, 959L, 960L, 961L, 962L,
963L, 964L, 965L, 966L, 967L, 968L, 969L, 970L, 971L, 972L, 973L,
974L, 975L, 976L, 977L, 978L, 979L, 980L, 981L, 982L, 983L, 984L,
985L, 986L, 987L, 988L, 989L, 990L, 991L, 992L, 993L, 994L, 995L,
996L, 997L, 998L, 999L, 1000L, 1001L, 1002L, 1003L, 1004L, 1005L,
1006L, 1007L, 1008L, 1009L, 1010L, 1011L, 1012L, 1013L, 1014L,
1015L, 1016L, 1017L, 1018L, 1019L, 1020L, 1021L, 1022L, 1023L,
1024L, 1025L, 1026L, 1027L, 1028L, 1029L, 1030L, 1031L, 1032L,
1033L, 1034L, 1035L, 1036L, 1037L, 1038L, 1039L, 1040L, 1041L,
1042L, 1043L, 1044L, 1045L, 1046L, 1047L, 1048L, 1049L, 1050L,
1201L, 1202L, 1203L, 1204L, 1205L, 1206L, 1207L, 1208L, 1209L,
1210L, 1211L, 1212L, 1213L, 1214L, 1215L, 1216L, 1217L, 1218L,
1219L, 1220L, 1221L, 1222L, 1223L, 1224L, 1225L, 1226L, 1227L,
1228L, 1229L, 1230L, 1231L, 1232L, 1233L, 1234L, 1235L, 1236L,
1237L, 1238L, 1239L, 1240L, 1241L, 1242L, 1243L, 1244L, 1245L,
1246L, 1247L, 1248L, 1249L, 1250L, 1251L, 1252L, 1253L, 1254L,
1255L, 1256L, 1257L, 1258L, 1259L, 1260L, 1261L, 1262L, 1263L,
1264L, 1265L, 1266L, 1267L, 1268L, 1269L, 1270L, 1271L, 1272L,
1273L, 1274L, 1275L, 1276L, 1277L, 1278L, 1279L, 1280L, 1281L,
1282L, 1283L, 1284L, 1285L, 1286L, 1287L, 1288L, 1289L, 1290L,
1291L, 1292L, 1293L, 1294L, 1295L, 1296L, 1297L, 1298L, 1299L,
1300L, 1301L, 1302L, 1303L, 1304L, 1305L, 1306L, 1307L, 1308L,
1309L, 1310L, 1311L, 1312L, 1313L, 1314L, 1315L, 1316L, 1317L,
1318L, 1319L, 1320L, 1321L, 1322L, 1323L, 1324L, 1325L, 1326L,
1327L, 1328L, 1329L, 1330L, 1331L, 1332L, 1333L, 1334L, 1335L,
1336L, 1337L, 1338L, 1339L, 1340L, 1341L, 1342L, 1343L, 1344L,
1345L, 1346L, 1347L, 1348L, 1349L, 1350L, 1501L, 1502L, 1503L,
1504L, 1505L, 1506L, 1507L, 1508L, 1509L, 1510L, 1511L, 1512L,
1513L, 1514L, 1515L, 1516L, 1517L, 1518L, 1519L, 1520L, 1521L,
1522L, 1523L, 1524L, 1525L, 1526L, 1527L, 1528L, 1529L, 1530L,
1531L, 1532L, 1533L, 1534L, 1535L, 1536L, 1537L, 1538L, 1539L,
1540L, 1541L, 1542L, 1543L, 1544L, 1545L, 1546L, 1547L, 1548L,
1549L, 1550L, 1551L, 1552L, 1553L, 1554L, 1555L, 1556L, 1557L,
1558L, 1559L, 1560L, 1561L, 1562L, 1563L, 1564L, 1565L, 1566L,
1567L, 1568L, 1569L, 1570L, 1571L, 1572L, 1573L, 1574L, 1575L,
1576L, 1577L, 1578L, 1579L, 1580L, 1581L, 1582L, 1583L, 1584L,
1585L, 1586L, 1587L, 1588L, 1589L, 1590L, 1591L, 1592L, 1593L,
1594L, 1595L, 1596L, 1597L, 1598L, 1599L, 1600L, 1601L, 1602L,
1603L, 1604L, 1605L, 1606L, 1607L, 1608L, 1609L, 1610L, 1611L,
1612L, 1613L, 1614L, 1615L, 1616L, 1617L, 1618L, 1619L, 1620L,
1621L, 1622L, 1623L, 1624L, 1625L, 1626L, 1627L, 1628L, 1629L,
1630L, 1631L, 1632L, 1633L, 1634L, 1635L, 1636L, 1637L, 1638L,
1639L, 1640L, 1641L, 1642L, 1643L, 1644L, 1645L, 1646L, 1647L,
1648L, 1649L, 1650L, 1801L, 1802L, 1803L, 1804L, 1805L, 1806L,
1807L, 1808L, 1809L, 1810L, 1811L, 1812L, 1813L, 1814L, 1815L,
1816L, 1817L, 1818L, 1819L, 1820L, 1821L, 1822L, 1823L, 1824L,
1825L, 1826L, 1827L, 1828L, 1829L, 1830L, 1831L, 1832L, 1833L,
1834L, 1835L, 1836L, 1837L, 1838L, 1839L, 1840L, 1841L, 1842L,
1843L, 1844L, 1845L, 1846L, 1847L, 1848L, 1849L, 1850L, 1851L,
1852L, 1853L, 1854L, 1855L, 1856L, 1857L, 1858L, 1859L, 1860L,
1861L, 1862L, 1863L, 1864L, 1865L, 1866L, 1867L, 1868L, 1869L,
1870L, 1871L, 1872L, 1873L, 1874L, 1875L, 1876L, 1877L, 1878L,
1879L, 1880L, 1881L, 1882L, 1883L, 1884L, 1885L, 1886L, 1887L,
1888L, 1889L, 1890L, 1891L, 1892L, 1893L, 1894L, 1895L, 1896L,
1897L, 1898L, 1899L, 1900L, 1901L, 1902L, 1903L, 1904L, 1905L,
1906L, 1907L, 1908L, 1909L, 1910L, 1911L, 1912L, 1913L, 1914L,
1915L, 1916L, 1917L, 1918L, 1919L, 1920L, 1921L, 1922L, 1923L,
1924L, 1925L, 1926L, 1927L, 1928L, 1929L, 1930L, 1931L, 1932L,
1933L, 1934L, 1935L, 1936L, 1937L, 1938L, 1939L, 1940L, 1941L,
1942L, 1943L, 1944L, 1945L, 1946L, 1947L, 1948L, 1949L, 1950L,
2101L, 2102L, 2103L, 2104L, 2105L, 2106L, 2107L, 2108L, 2109L,
2110L, 2111L, 2112L, 2113L, 2114L, 2115L, 2116L, 2117L, 2118L,
2119L, 2120L, 2121L, 2122L, 2123L, 2124L, 2125L, 2126L, 2127L,
2128L, 2129L, 2130L, 2131L, 2132L, 2133L, 2134L, 2135L, 2136L,
2137L, 2138L, 2139L, 2140L, 2141L, 2142L, 2143L, 2144L, 2145L,
2146L, 2147L, 2148L, 2149L, 2150L, 2151L, 2152L, 2153L, 2154L,
2155L, 2156L, 2157L, 2158L, 2159L, 2160L, 2161L, 2162L, 2163L,
2164L, 2165L, 2166L, 2167L, 2168L, 2169L, 2170L, 2171L, 2172L,
2173L, 2174L, 2175L, 2176L, 2177L, 2178L, 2179L, 2180L, 2181L,
2182L, 2183L, 2184L, 2185L, 2186L, 2187L, 2188L, 2189L, 2190L,
2191L, 2192L, 2193L, 2194L, 2195L, 2196L, 2197L, 2198L, 2199L,
2200L, 2201L, 2202L, 2203L, 2204L, 2205L, 2206L, 2207L, 2208L,
2209L, 2210L, 2211L, 2212L, 2213L, 2214L, 2215L, 2216L, 2217L,
2218L, 2219L, 2220L, 2221L, 2222L, 2223L, 2224L, 2225L, 2226L,
2227L, 2228L, 2229L, 2230L, 2231L, 2232L, 2233L, 2234L, 2235L,
2236L, 2237L, 2238L, 2239L, 2240L, 2241L, 2242L, 2243L, 2244L,
2245L, 2246L, 2247L, 2248L, 2249L, 2250L), class = "data.frame")
到目前为止进行分箱的方法......
timevec = seq(min(sums$difftim), max(sums$difftim), by=round( (max(sums$difftim) - min(sums$difftim))/8 ) )
#cut
sumstab = xtabs(~ratperc +cut(difftim, timevec ), dat=sumsid1)
#to dataframe
sumstab = data.frame(sumstab)
#rename
colnames(sumstab) = c("rating", "range", "freq")
#convert rating to numeric
sumstab$rating = as.numeric(as.character(sumstab$rating))
#prepare data for summary
sumstab$fresum = sumstab$rating * sumstab$freq
sumstab2 = ddply(sumstab, .(range), summarise, meanrat = sum(fresum)/sum(freq), no_obs = sum(freq))
我认为最简单的方法是找到一种需要一种新方法来计算timevec
我用于cut
数据的向量。但是,如果有人知道做整个事情的更好方法,请告诉我。谢谢!