polynomial contrast aver repeated measure anova and robust repeated measure anova - r

I want to see how persons adherence over a 10 week trial develop. The hypothesis is that it drops in a linear matter.
Therefore I'm computing a one-way repeated measures anova.
aovcar1 <- aov_car(adherence ~ week + Error(id / week), data = data_long)
to check for the linear trend I'm using:
aovcar1_fi_con <- aovcar1_fi %>% lsmeans(specs = ~ week) %>% contrast(method = "poly")
but the assumption of normality of residuals and the assumption of sphericity are not met
therefore I want to compute a robust anova
rmanova <-rmanovab(data_long$adherence, data_long$week, data_long$id, tr =.2, alpha =.05, nboot = 1500)
I can't find a way to compute a polynomial contrast based on the robust anova. What is available is the "pairdepb" function that computes pairwise comparisons.
in addition:
when computing the polynomial contrasts with the non robust anova more than one is getting significant - can someone explain how this needs to be interpreted?
The results are below:
contrast estimate SE df t.ratio p.value
linear -0.6986 0.371 254 -1.884 0.0607
quadratic -0.3922 0.165 254 -2.380 0.0181
cubic 3.7669 1.064 254 3.540 0.0005
quartic -1.4084 0.527 254 -2.673 0.0080
degree 5 0.5703 0.265 254 2.148 0.0326
degree 6 0.0056 0.214 254 0.026 0.9791
the corresponding dput was to long I am fixing this right now
dput(stack_exchange_new)
structure(list(obfuscated_user_id = structure(c(9L, 30L, 87L,
95L, 97L, 100L, 108L, 151L, 157L, 163L, 164L, 167L, 192L, 194L,
196L, 203L, 206L, 208L, 209L, 210L, 213L, 217L, 219L, 230L, 231L,
25L, 28L, 29L, 33L, 34L, 36L, 37L, 38L, 39L, 41L, 42L, 88L, 89L,
90L, 91L, 92L, 93L, 96L, 98L, 99L, 101L, 102L, 103L, 104L, 106L,
148L, 149L, 150L, 154L, 155L, 156L, 161L, 162L, 165L, 166L, 168L,
190L, 191L, 193L, 195L, 198L, 199L, 200L, 202L, 204L, 205L, 207L,
215L, 216L, 220L, 222L, 223L, 224L, 226L, 227L, 229L, 245L, 253L,
254L, 40L, 86L, 158L, 160L, 211L, 212L, 225L, 152L, 153L, 197L,
214L, 218L, 255L, 85L, 94L, 105L, 228L, 159L, 35L, 201L, 221L,
9L, 30L, 87L, 95L, 97L, 100L, 108L, 151L, 157L, 163L, 164L, 167L,
192L, 194L, 196L, 203L, 206L, 208L, 209L, 210L, 213L, 217L, 219L,
230L, 231L, 25L, 28L, 29L, 33L, 34L, 36L, 37L, 38L, 39L, 41L,
42L, 88L, 89L, 90L, 91L, 92L, 93L, 96L, 98L, 99L, 101L, 102L,
103L, 104L, 106L, 148L, 149L, 150L, 154L, 155L, 156L, 161L, 162L,
165L, 166L, 168L, 190L, 191L, 193L, 195L, 198L, 199L, 200L, 202L,
204L, 205L, 207L, 215L, 216L, 220L, 222L, 223L, 224L, 226L, 227L,
229L, 245L, 253L, 254L, 40L, 86L, 158L, 160L, 211L, 212L, 225L,
152L, 153L, 197L, 214L, 218L, 255L, 85L, 94L, 105L, 228L, 159L,
35L, 201L, 221L, 9L, 30L, 87L, 95L, 97L, 100L, 108L, 151L, 157L,
163L, 164L, 167L, 192L, 194L, 196L, 203L, 206L, 208L, 209L, 210L,
213L, 217L, 219L, 230L, 231L, 25L, 28L, 29L, 33L, 34L, 36L, 37L,
38L, 39L, 41L, 42L, 88L, 89L, 90L, 91L, 92L, 93L, 96L, 98L, 99L,
101L, 102L, 103L, 104L, 106L, 148L, 149L, 150L, 154L, 155L, 156L,
161L, 162L, 165L, 166L, 168L, 190L, 191L, 193L, 195L, 198L, 199L,
200L, 202L, 204L, 205L, 207L, 215L, 216L, 220L, 222L, 223L, 224L,
226L, 227L, 229L, 245L, 253L, 254L, 40L, 86L, 158L, 160L, 211L,
212L, 225L, 152L, 153L, 197L, 214L, 218L, 255L, 85L, 94L, 105L,
228L, 159L, 35L, 201L, 221L, 9L, 30L, 87L, 95L, 97L, 100L, 108L,
151L, 157L, 163L, 164L, 167L, 192L, 194L, 196L, 203L, 206L, 208L,
209L, 210L, 213L, 217L, 219L, 230L, 231L, 25L, 28L, 29L, 33L,
34L, 36L, 37L, 38L, 39L, 41L, 42L, 88L, 89L, 90L, 91L, 92L, 93L,
96L, 98L, 99L, 101L, 102L, 103L, 104L, 106L, 148L, 149L, 150L,
154L, 155L, 156L, 161L, 162L, 165L, 166L, 168L, 190L, 191L, 193L,
195L, 198L, 199L, 200L, 202L, 204L, 205L, 207L, 215L, 216L, 220L,
222L, 223L, 224L, 226L, 227L, 229L, 245L, 253L, 254L, 40L, 86L,
158L, 160L, 211L, 212L, 225L, 152L, 153L, 197L, 214L, 218L, 255L,
85L, 94L, 105L, 228L, 159L, 35L, 201L, 221L, 9L, 30L, 87L, 95L,
97L, 100L, 108L, 151L, 157L, 163L, 164L, 167L, 192L, 194L, 196L,
203L, 206L, 208L, 209L, 210L, 213L, 217L, 219L, 230L, 231L, 25L,
28L, 29L, 33L, 34L, 36L, 37L, 38L, 39L, 41L, 42L, 88L, 89L, 90L,
91L, 92L, 93L, 96L, 98L, 99L, 101L, 102L, 103L, 104L, 106L, 148L,
149L, 150L, 154L, 155L, 156L, 161L, 162L, 165L, 166L, 168L, 190L,
191L, 193L, 195L, 198L, 199L, 200L, 202L, 204L, 205L, 207L, 215L,
216L, 220L, 222L, 223L, 224L, 226L, 227L, 229L, 245L, 253L, 254L,
40L, 86L, 158L, 160L, 211L, 212L, 225L, 152L, 153L, 197L, 214L,
218L, 255L, 85L, 94L, 105L, 228L, 159L, 35L, 201L, 221L, 9L,
30L, 87L, 95L, 97L, 100L, 108L, 151L, 157L, 163L, 164L, 167L,
192L, 194L, 196L, 203L, 206L, 208L, 209L, 210L, 213L, 217L, 219L,
230L, 231L, 25L, 28L, 29L, 33L, 34L, 36L, 37L, 38L, 39L, 41L,
42L, 88L, 89L, 90L, 91L, 92L, 93L, 96L, 98L, 99L, 101L, 102L,
103L, 104L, 106L, 148L, 149L, 150L, 154L, 155L, 156L, 161L, 162L,
165L, 166L, 168L, 190L, 191L, 193L, 195L, 198L, 199L, 200L, 202L,
204L, 205L, 207L, 215L, 216L, 220L, 222L, 223L, 224L, 226L, 227L,
229L, 245L, 253L, 254L, 40L, 86L, 158L, 160L, 211L, 212L, 225L,
152L, 153L, 197L, 214L, 218L, 255L, 85L, 94L, 105L, 228L, 159L,
35L, 201L, 221L, 9L, 30L, 87L, 95L, 97L, 100L, 108L, 151L, 157L,
163L, 164L, 167L, 192L, 194L, 196L, 203L, 206L, 208L, 209L, 210L,
213L, 217L, 219L, 230L, 231L, 25L, 28L, 29L, 33L, 34L, 36L, 37L,
38L, 39L, 41L, 42L, 88L, 89L, 90L, 91L, 92L, 93L, 96L, 98L, 99L,
101L, 102L, 103L, 104L, 106L, 148L, 149L, 150L, 154L, 155L, 156L,
161L, 162L, 165L, 166L, 168L, 190L, 191L, 193L, 195L, 198L, 199L,
200L, 202L, 204L, 205L, 207L, 215L, 216L, 220L, 222L, 223L, 224L,
226L, 227L, 229L, 245L, 253L, 254L, 40L, 86L, 158L, 160L, 211L,
212L, 225L, 152L, 153L, 197L, 214L, 218L, 255L, 85L, 94L, 105L,
228L, 159L, 35L, 201L, 221L, 9L, 30L, 87L, 95L, 97L, 100L, 108L,
151L, 157L, 163L, 164L, 167L, 192L, 194L, 196L, 203L, 206L, 208L,
209L, 210L, 213L, 217L, 219L, 230L, 231L, 25L, 28L, 29L, 33L,
34L, 36L, 37L, 38L, 39L, 41L, 42L, 88L, 89L, 90L, 91L, 92L, 93L,
96L, 98L, 99L, 101L, 102L, 103L, 104L, 106L, 148L, 149L, 150L,
154L, 155L, 156L, 161L, 162L, 165L, 166L, 168L, 190L, 191L, 193L,
195L, 198L, 199L, 200L, 202L, 204L, 205L, 207L, 215L, 216L, 220L,
222L, 223L, 224L, 226L, 227L, 229L, 245L, 253L, 254L, 40L, 86L,
158L, 160L, 211L, 212L, 225L, 152L, 153L, 197L, 214L, 218L, 255L,
85L, 94L, 105L, 228L, 159L, 35L, 201L, 221L, 9L, 30L, 87L, 95L,
97L, 100L, 108L, 151L, 157L, 163L, 164L, 167L, 192L, 194L, 196L,
203L, 206L, 208L, 209L, 210L, 213L, 217L, 219L, 230L, 231L, 25L,
28L, 29L, 33L, 34L, 36L, 37L, 38L, 39L, 41L, 42L, 88L, 89L, 90L,
91L, 92L, 93L, 96L, 98L, 99L, 101L, 102L, 103L, 104L, 106L, 148L,
149L, 150L, 154L, 155L, 156L, 161L, 162L, 165L, 166L, 168L, 190L,
191L, 193L, 195L, 198L, 199L, 200L, 202L, 204L, 205L, 207L, 215L,
216L, 220L, 222L, 223L, 224L, 226L, 227L, 229L, 245L, 253L, 254L,
40L, 86L, 158L, 160L, 211L, 212L, 225L, 152L, 153L, 197L, 214L,
218L, 255L, 85L, 94L, 105L, 228L, 159L, 35L, 201L, 221L, 9L,
30L, 87L, 95L, 97L, 100L, 108L, 151L, 157L, 163L, 164L, 167L,
192L, 194L, 196L, 203L, 206L, 208L, 209L, 210L, 213L, 217L, 219L,
230L, 231L, 25L, 28L, 29L, 33L, 34L, 36L, 37L, 38L, 39L, 41L,
42L, 88L, 89L, 90L, 91L, 92L, 93L, 96L, 98L, 99L, 101L, 102L,
103L, 104L, 106L, 148L, 149L, 150L, 154L, 155L, 156L, 161L, 162L,
165L, 166L, 168L, 190L, 191L, 193L, 195L, 198L, 199L, 200L, 202L,
204L, 205L, 207L, 215L, 216L, 220L, 222L, 223L, 224L, 226L, 227L,
229L, 245L, 253L, 254L, 40L, 86L, 158L, 160L, 211L, 212L, 225L,
152L, 153L, 197L, 214L, 218L, 255L, 85L, 94L, 105L, 228L, 159L,
35L, 201L, 221L), .Label = c("3", "14", "21", "25", "26", "27",
"34", "35", "41", "45", "48", "54", "57", "58", "61", "71", "80",
"91", "97", "99", "103", "104", "132", "134", "136", "142", "148",
"149", "161", "179", "191", "196", "212", "232", "238", "241",
"255", "263", "266", "267", "268", "272", "276", "277", "296",
"309", "310", "320", "322", "331", "333", "334", "336", "338",
"347", "357", "368", "373", "381", "393", "397", "403", "404",
"417", "418", "425", "426", "432", "434", "439", "440", "442",
"461", "463", "465", "476", "477", "481", "489", "502", "514",
"524", "548", "557", "562", "564", "569", "573", "574", "596",
"598", "603", "618", "634", "645", "654", "677", "679", "680",
"690", "709", "726", "751", "762", "763", "767", "771", "780",
"783", "787", "790", "794", "799", "811", "819", "820", "831",
"838", "839", "840", "858", "864", "865", "868", "873", "875",
"879", "881", "892", "896", "897", "906", "910", "915", "917",
"930", "932", "936", "953", "960", "963", "964", "995", "998",
"1005", "1012", "1019", "1026", "1061", "1067", "1072", "1077",
"1085", "1088", "1111", "1133", "1147", "1178", "1182", "1189",
"1192", "1196", "1201", "1204", "1218", "1222", "1238", "1251",
"1253", "1258", "1259", "1262", "1263", "1272", "1277", "1278",
"1280", "1318", "1321", "1327", "1338", "1350", "1354", "1358",
"1367", "1370", "1383", "1392", "1395", "1398", "1405", "1409",
"1420", "1421", "1423", "1439", "1443", "1460", "1465", "1471",
"1481", "1484", "1486", "1487", "1513", "1516", "1527", "1531",
"1533", "1535", "1536", "1569", "1577", "1581", "1597", "1602",
"1615", "1625", "1636", "1644", "1651", "1653", "1654", "1661",
"1663", "1676", "1681", "1697", "1698", "1707", "1725", "1727",
"1739", "1741", "1754", "1772", "1773", "1775", "1778", "1781",
"1791", "1801", "1805", "1808", "1809", "1811", "1839", "1859",
"1860", "1866", "1872", "1878", "1880", "1884", "1889"), class = "factor"),
adherence = c(0.428571428571429, 0.714285714285714, 0.428571428571429,
0, 0.285714285714286, 0, 0, 0.142857142857143, 0.142857142857143,
0, 0, 0, 0.285714285714286, 0.285714285714286, 0, 0, 0.571428571428571,
0.285714285714286, 0, 0.142857142857143, 0, 0.571428571428571,
0.857142857142857, 0.142857142857143, 0, 0, 0, 1, 0, 0, 0.571428571428571,
0.571428571428571, 1, 0, 0.857142857142857, 0, 0.857142857142857,
0, 1, 0, 0.142857142857143, 0, 0.428571428571429, 0.142857142857143,
0.571428571428571, 0.571428571428571, 0.714285714285714,
0, 0, 0.857142857142857, 0, 0.571428571428571, 0, 0.571428571428571,
0.428571428571429, 0.142857142857143, 0.428571428571429,
0, 1, 0, 0.714285714285714, 1, 0, 1, 0.571428571428571, 0,
0.571428571428571, 0, 0.142857142857143, 0.857142857142857,
0.714285714285714, 0, 0, 0, 0.428571428571429, 0.714285714285714,
0, 0, 0.142857142857143, 0, 0, 0, 0, 0.714285714285714, 0,
0, 0.285714285714286, 1, 0, 0, 0.142857142857143, 0.857142857142857,
0, 1, 0.857142857142857, 0, 0, 1, 0.285714285714286, 0.428571428571429,
0, 0, 0, 0, 0.714285714285714, 0, 0.857142857142857, 0.285714285714286,
0.142857142857143, 0.714285714285714, 0, 0, 0.714285714285714,
0.714285714285714, 0, 0, 0, 0.857142857142857, 0.571428571428571,
0, 0, 0.142857142857143, 0.428571428571429, 0, 1, 0.857142857142857,
0.714285714285714, 0, 0.714285714285714, 0.142857142857143,
0.142857142857143, 0, 1, 0.142857142857143, 0, 1, 1, 1, 0,
0.714285714285714, 0.428571428571429, 1, 0, 0.857142857142857,
0, 0.285714285714286, 0, 0.571428571428571, 0, 0.714285714285714,
0.428571428571429, 0, 0, 0, 0.285714285714286, 0, 0.571428571428571,
0, 0.285714285714286, 0.285714285714286, 0.714285714285714,
0, 0, 1, 0, 0, 1, 0.142857142857143, 1, 0.714285714285714,
0.285714285714286, 1, 0.428571428571429, 0.285714285714286,
1, 0.428571428571429, 0, 0.571428571428571, 0.285714285714286,
0.285714285714286, 1, 0, 0.428571428571429, 0, 0, 0.142857142857143,
0.142857142857143, 0, 1, 0, 0, 0.428571428571429, 1, 0, 0,
0, 1, 0, 1, 0.571428571428571, 0, 0, 1, 0.285714285714286,
0, 0, 0, 0, 0.142857142857143, 0.571428571428571, 0, 1, 0.142857142857143,
0, 0.571428571428571, 0, 0, 1, 0, 0, 0, 0, 0.285714285714286,
0.428571428571429, 0, 0, 0, 0, 0.142857142857143, 1, 0.142857142857143,
1, 0, 0.857142857142857, 0, 0, 0, 1, 0, 0, 0.714285714285714,
1, 1, 0, 0, 0, 0.714285714285714, 0.142857142857143, 1, 0,
0, 0, 0.571428571428571, 0.714285714285714, 0.857142857142857,
0.714285714285714, 0.571428571428571, 0, 0, 0.714285714285714,
0, 0.571428571428571, 0, 0.285714285714286, 0.285714285714286,
0.571428571428571, 0, 0.571428571428571, 1, 0, 0.571428571428571,
1, 0, 1, 0.857142857142857, 0.285714285714286, 0.714285714285714,
0.714285714285714, 0.285714285714286, 1, 0.285714285714286,
0, 0.714285714285714, 0.285714285714286, 0.857142857142857,
1, 0, 0.571428571428571, 0, 0, 0.142857142857143, 0.571428571428571,
0, 1, 0.428571428571429, 0, 0.285714285714286, 0.857142857142857,
0, 0, 0, 1, 0.142857142857143, 1, 0.571428571428571, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0.142857142857143, 0, 1, 0.285714285714286,
0, 0.714285714285714, 0, 0, 0.428571428571429, 0, 0, 0, 0,
1, 0.714285714285714, 0, 0, 0, 0, 0, 1, 0.142857142857143,
1, 0, 1, 0, 0, 0, 0.285714285714286, 0.285714285714286, 0,
0.714285714285714, 1, 1, 0, 0, 0, 0.714285714285714, 1, 1,
0, 0.142857142857143, 0, 0.571428571428571, 1, 0.571428571428571,
0.428571428571429, 0.285714285714286, 0, 0, 0.571428571428571,
0, 0.285714285714286, 0, 0.142857142857143, 0.142857142857143,
1, 0, 0.571428571428571, 1, 0, 0.285714285714286, 1, 0.142857142857143,
1, 0.714285714285714, 0.714285714285714, 0.714285714285714,
0.571428571428571, 0.142857142857143, 0.857142857142857,
0.142857142857143, 0, 0.428571428571429, 0, 0.857142857142857,
1, 0.428571428571429, 0.428571428571429, 0, 0, 0, 0.571428571428571,
0, 0.857142857142857, 0.142857142857143, 0, 0.285714285714286,
0.857142857142857, 0, 0, 0, 1, 0.142857142857143, 1, 0.428571428571429,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0.142857142857143, 0, 0.857142857142857,
0.714285714285714, 0, 0.571428571428571, 0, 0, 0.714285714285714,
0, 0, 0.142857142857143, 0, 0.285714285714286, 0.857142857142857,
0, 0, 0.142857142857143, 0, 0, 1, 0.142857142857143, 1, 0,
0.714285714285714, 0.285714285714286, 0, 0, 0, 0, 0, 0.714285714285714,
1, 0.857142857142857, 0, 0, 0, 0.857142857142857, 1, 1, 0,
0, 0, 0.571428571428571, 1, 0.571428571428571, 0.285714285714286,
0.142857142857143, 0, 0, 0.285714285714286, 0, 0, 0, 0.285714285714286,
0.142857142857143, 0.571428571428571, 0.142857142857143,
0, 1, 0, 0.428571428571429, 1, 0, 0.857142857142857, 0.571428571428571,
0, 1, 0.571428571428571, 0.142857142857143, 1, 0.142857142857143,
0, 0.571428571428571, 0, 0.571428571428571, 0, 0.428571428571429,
0.571428571428571, 0, 0, 0, 0.142857142857143, 0, 1, 0, 0,
0.142857142857143, 0.857142857142857, 0, 0, 0, 1, 0.142857142857143,
1, 0.571428571428571, 0, 0, 1, 0, 0, 0, 0, 0, 0.285714285714286,
0, 0, 0.857142857142857, 0.428571428571429, 0, 0.428571428571429,
0, 0, 0.857142857142857, 0.142857142857143, 0, 0, 0, 0, 0.714285714285714,
0, 0, 0, 0, 0, 1, 0.571428571428571, 1, 0, 1, 0.142857142857143,
0.142857142857143, 0, 0, 0.142857142857143, 0, 0, 0.857142857142857,
1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0.714285714285714, 1, 0.428571428571429,
0.428571428571429, 0.285714285714286, 0, 0, 0, 0, 0, 0, 0.571428571428571,
0.285714285714286, 0.571428571428571, 0.142857142857143,
0, 1, 0.142857142857143, 0.428571428571429, 1, 0, 1, 0.428571428571429,
0.571428571428571, 0.857142857142857, 0.142857142857143,
0, 0.857142857142857, 0, 0, 0.428571428571429, 0.285714285714286,
1, 0, 0.714285714285714, 0.857142857142857, 0, 0, 0, 0.857142857142857,
0, 1, 0, 0, 0, 0.857142857142857, 0, 0.142857142857143, 0,
0.857142857142857, 0, 1, 0.571428571428571, 0, 0, 1, 0, 0,
0, 0, 0, 0.142857142857143, 0, 0, 1, 0.428571428571429, 0,
0.285714285714286, 0, 0, 0.714285714285714, 0.285714285714286,
0, 0, 0, 0.571428571428571, 0.571428571428571, 0.142857142857143,
0.285714285714286, 0, 0, 0, 1, 0.142857142857143, 1, 0, 1,
0.285714285714286, 0, 0, 0, 0, 0, 0.142857142857143, 1, 1,
0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0.857142857142857, 0, 0.428571428571429,
0, 0, 0, 0.285714285714286, 0, 0, 0, 0.714285714285714, 0.428571428571429,
0.714285714285714, 0, 0, 1, 0.428571428571429, 1, 1, 0, 1,
0.142857142857143, 0.285714285714286, 0.857142857142857,
0.428571428571429, 0, 1, 0, 0, 0.571428571428571, 0.571428571428571,
0.571428571428571, 0, 0.428571428571429, 1, 0, 0, 0, 0.571428571428571,
0, 1, 0.142857142857143, 0, 0, 0.857142857142857, 0, 0, 0,
0.857142857142857, 0.285714285714286, 1, 0.857142857142857,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0.142857142857143, 0,
0, 0, 0, 0.571428571428571, 0, 0, 0, 0, 0.285714285714286,
0.714285714285714, 0.285714285714286, 0, 0, 0, 0, 1, 0, 1,
0, 1, 0.714285714285714, 0, 0, 0, 0, 0, 0.428571428571429,
1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0.857142857142857, 0.285714285714286,
0.285714285714286, 0, 0, 0, 0.142857142857143, 0, 0, 0, 0.285714285714286,
0.714285714285714, 0.571428571428571, 0, 0.142857142857143,
1, 0.142857142857143, 0.428571428571429, 1, 0.142857142857143,
1, 0.571428571428571, 0.285714285714286, 0.857142857142857,
0.857142857142857, 0, 1, 0, 0, 0.428571428571429, 0.428571428571429,
0, 0, 0, 1, 0, 0, 0, 0.571428571428571, 0, 1, 0.285714285714286,
0, 0, 1, 0, 0, 0, 0.857142857142857, 0.142857142857143, 1,
0.571428571428571, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0.714285714285714,
0, 0, 0.142857142857143, 0, 0, 0, 0, 0, 0, 0, 0, 0.857142857142857,
0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0.571428571428571, 0, 0, 0,
0, 0, 0.285714285714286, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0.428571428571429, 0.428571428571429, 0, 0.142857142857143,
0, 0, 0.142857142857143, 0, 0.142857142857143, 0, 0.571428571428571,
0.571428571428571, 0.571428571428571, 0, 0.714285714285714,
1, 0, 0.571428571428571, 1, 0, 1, 0.857142857142857, 0, 0.571428571428571,
0.571428571428571, 0, 1, 0, 0, 0.142857142857143, 0.571428571428571,
0, 0, 0.571428571428571, 0.571428571428571, 0, 0, 0, 0.571428571428571,
0, 1, 0.142857142857143, 0, 0, 1, 0, 0, 0, 0.571428571428571,
0, 1, 0.714285714285714, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0.714285714285714, 0, 0.142857142857143, 0, 0, 0, 0, 0,
0.142857142857143, 0, 0.142857142857143, 0.857142857142857,
0, 0.142857142857143, 0, 0, 0, 1, 0, 1, 0, 1, 0.285714285714286,
0, 0, 0, 0, 0, 0.428571428571429, 1, 1, 0, 0, 0, 1, 1, 1,
0, 0, 0, 0, 0.285714285714286, 0.571428571428571, 0.571428571428571,
0, 0, 0, 0.428571428571429, 0, 0, 0, 0.142857142857143, 0.142857142857143,
0.571428571428571, 0.142857142857143, 0.428571428571429,
1, 0.142857142857143, 0, 0.857142857142857, 0, 1, 0.714285714285714,
0.142857142857143, 0.285714285714286, 0.857142857142857,
0, 1, 0, 0, 0.142857142857143, 0.428571428571429, 0, 0, 0,
0.857142857142857, 0, 0, 0, 0.285714285714286, 0, 1, 0, 0,
0, 1, 0, 0, 0, 0.428571428571429, 0, 1, 0.714285714285714,
0, 0, 1, 0, 0, 0, 0.142857142857143, 0, 0, 0.142857142857143
), week = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L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, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L), .Label = c("week.g.0", "week.g.1",
"week.g.2", "week.g.3", "week.g.4", "week.g.5",
"week.g.6", "week.g.7", "week.g.8", "week.g.9"
), class = "factor")), row.names = c(NA, -1050L), class = c("tbl_df",
"tbl", "data.frame"))

Related

How to plot a ROC curve from TPR and FPR

I have a case where I only get TP, FP, FN and TN for every single data point (one example). In total, I have 24 examples (data points) with these 4 measures. I use 2 different methods and compute TP, FP, FN and TN for each example (data point). Now, I want to compare the performance of these 2 different methods by plotting a ROC curve. I have calculated TPR (y-axis) and FPR (x-axis) and plot them using ggplot2 (see image link) but I don't know how can I fit the curves on these data points so that they look like classical/traditional ROC curve plots. SO that I can also compute the auROC curve.
Can somebody guide me how to do it? Thank you.
plot using ggplot:
ggplot(data, aes(x=FPR, y=TPR)) + geom_point(aes(shape=Class, colour = Class), size=1.5) + scale_shape(solid = FALSE) + theme_update(plot.title=element_text(hjust=0.5)) + xlim(0,1) + xlab("False Positive Rate (FPR)") + ylab("True Positive Rate (TPR)")
Here is the dput of my data:
> dput(data)
structure(list(Class = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Epi",
"GE"), class = "factor"), TP = c(94L, 127L, 58L, 76L, 5L, 6L,
34L, 47L, 14L, 20L, 113L, 136L, 32L, 36L, 78L, 102L, 51L, 58L,
49L, 50L, 111L, 120L, 174L, 184L, 151L, 172L, 189L, 226L, 36L,
40L, 252L, 271L, 2L, 4L, 7L, 42L, 41L, 82L, 0L, 15L, 45L, 53L,
11L, 16L, 24L, 35L, 3L, 10L, 28L, 34L), FP = c(46L, 389L, 3L,
254L, 3L, 7L, 13L, 57L, 7L, 88L, 55L, 220L, 21L, 87L, 23L, 245L,
11L, 190L, 20L, 77L, 45L, 168L, 86L, 391L, 34L, 238L, 88L, 367L,
56L, 193L, 119L, 455L, 3L, 27L, 5L, 30L, 67L, 247L, 0L, 30L,
4L, 65L, 7L, 77L, 55L, 176L, 5L, 33L, 15L, 66L), FN = c(33L,
0L, 18L, 0L, 1L, 0L, 13L, 0L, 6L, 0L, 23L, 0L, 4L, 0L, 24L, 0L,
7L, 0L, 1L, 0L, 9L, 0L, 10L, 0L, 21L, 0L, 37L, 0L, 4L, 0L, 19L,
0L, 5L, 3L, 35L, 0L, 41L, 0L, 15L, 0L, 8L, 0L, 6L, 1L, 14L, 3L,
7L, 0L, 6L, 0L), TN = c(488L, 179L, 373L, 125L, 10L, 6L, 75L,
32L, 119L, 38L, 247L, 83L, 97L, 37L, 400L, 179L, 295L, 132L,
107L, 51L, 200L, 109L, 441L, 140L, 331L, 157L, 419L, 177L, 180L,
45L, 567L, 237L, 35L, 11L, 88L, 91L, 222L, 90L, 0L, 29L, 116L,
56L, 105L, 36L, 217L, 99L, 55L, 28L, 82L, 32L), TPR = c(0.74,
1, 0.76, 1, 0.83, 1, 0.72, 1, 0.7, 1, 0.83, 1, 0.89, 1, 0.76,
1, 0.88, 1, 0.98, 1, 0.92, 1, 0.95, 1, 0.88, 1, 0.84, 1, 0.9,
1, 0.93, 1, 0.29, 0.57, 0.17, 1, 0.5, 1, 0, 1, 0.85, 1, 0.65,
0.94, 0.63, 0.92, 0.3, 1, 0.82, 1), FPR = c(0.09, 0.68, 0.01,
0.67, 0.23, 0.54, 0.15, 0.64, 0.06, 0.7, 0.18, 0.73, 0.18, 0.7,
0.05, 0.58, 0.04, 0.59, 0.16, 0.6, 0.18, 0.61, 0.16, 0.74, 0.09,
0.6, 0.17, 0.67, 0.24, 0.81, 0.17, 0.66, 0.08, 0.71, 0.05, 0.25,
0.23, 0.73, NA, 0.51, 0.03, 0.54, 0.06, 0.68, 0.2, 0.64, 0.08,
0.54, 0.15, 0.67)), .Names = c("Class", "TP", "FP", "FN", "TN",
"TPR", "FPR"), class = "data.frame", row.names = c(NA, -50L))
EDIT:
This is how the header of data looks like:
> head(data)
Class TP FP FN TN TPR FPR
1 Epi 94 46 33 488 0.74 0.09
2 GE 127 389 0 179 1.00 0.68
3 Epi 58 3 18 373 0.76 0.01
4 GE 76 254 0 125 1.00 0.67
5 Epi 5 3 1 10 0.83 0.23
6 GE 6 7 0 6 1.00 0.54
I will explain the first 2 rows, the same explantation applies to the rest of them. I used 2 different methods (named Epi and GE) to calculate number of TP, FP, FN and TN in my predictions about 1 example ( represented in plot by 1 data point). Then I calculate TPR and FPR from them. Similarly, the same 2 methods I applied on rest of the 23 examples and this entire dataframe gives me the value of TP, FP, FN and TN for each method in every example (24 datapoints - 1 data point representing one example and its TPR/FPR rate calculated by one method i.e. either GE or Epi).

Iteration over all variables in a dataframe

I have found a useful mean imputation technique here
.
More specifically:
variable[is.na(variable)] <- rowMeans(cbind(variable[which(is.na(variable))-1],
variable[which(is.na(variable))+1]))
Which takes values before and after the missing one and imputes their mean.
However, since I have a large data frame with lots of variables I was wondering is there a way to iterate this function over every variable (column) in the df?
dput:
dput(head(politbar_timeseries,10))
structure(list(Month = structure(c(8401, 8432, 8460, 8491, 8521,
8552, 8582, 8613, 8644, 8674), class = "Date"), Intention_CDU = c(246L,
223L, 222L, 232L, 261L, 240L, 241L, NA, 234L, 211L), Intention_SPD = c(304L,
323L, 276L, 274L, 238L, 290L, 291L, NA, 284L, 296L), Intention_FDP = c(47L,
44L, 46L, 36L, 35L, 50L, 31L, NA, 33L, 40L), Intention_Green = c(112L,
90L, 108L, 97L, 92L, 93L, 80L, NA, 131L, 97L), Intention_PDS = c(1L,
2L, 1L, 4L, 2L, 4L, 6L, NA, 3L, 1L), Intention_Right = c(40L,
45L, 51L, 44L, 48L, 26L, 30L, NA, 33L, 39L), CDU_CSU_Scale = c(5.53364976051333,
5.41668954145634, 5.41361737597252, 5.53237142973321, 5.90556125077522,
5.65325991093138, 5.66581907651607, NA, 5.7568395653053, 5.56722081960557
), SPD_Scale = c(6.68501038883942, 7.0740019675866, 6.31415136355633,
6.52447895467401, 6.29176231355408, 6.52870415235848, 6.73302006301497,
NA, 7.12547563426403, 7.17833309669175), FDP_Scale = c(5.34570000100596,
5.73343004031828, 5.52174547729524, 5.39618098094715, 5.81980921102384,
5.64326882828348, 5.70136552543044, NA, 5.3836387964029, 5.73726720856055
), Grüne_Scale = c(5.73191750379599, 6.03715643205545, 6.19893648691653,
5.96106479727169, 5.78436018957346, 5.54482751153172, 5.6213169156508,
NA, 6.42776109093573, 6.33016932291559), Republikaner_Scale = c(2.33415238404679,
2.40200426439232, 2.50591428720572, 2.45599753445912, 2.61170073660812,
2.26120872300811, 2.24409536048212, NA, 2.29699201198203, 2.25876734042663
), PDS_Scale = c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NA, NaN,
NaN)), .Names = c("Month", "Intention_CDU", "Intention_SPD",
"Intention_FDP", "Intention_Green", "Intention_PDS", "Intention_Right",
"CDU_CSU_Scale", "SPD_Scale", "FDP_Scale", "Grüne_Scale", "Republikaner_Scale",
"PDS_Scale"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 249L,
8L, 9L), class = "data.frame")

Is `format` more secure than `$` when extracting hours from a POSIXlt vector?

Starting R with a bare-bone
l#np350v5c:~$ R --vanilla
> search()
[1] ".GlobalEnv" "package:stats" "package:graphics"
[4] "package:grDevices" "package:utils" "package:datasets"
[7] "package:methods" "Autoloads" "package:base"
.. this is a dump of data (emergency accesses hours in a northern Italy hospital) which gave a strange (to me) behaviour:
times <- structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0), min = c(5L, 43L, 2L, 47L, 15L, 18L, 46L, 50L, 58L,
26L, 14L, 54L, 28L, 11L, 32L, 17L, 51L, 40L, 17L, 47L, 21L, 57L,
59L, 34L, 45L, 15L, 10L, 25L, 27L, 31L, 5L, 34L, 5L, 36L, 16L,
2L, 20L, 0L, 24L, 1L, 54L, 59L, 28L, 24L, 24L, 19L, 26L, 1L,
48L, 0L, 10L, 18L, 43L, 38L, 24L, 21L, 37L, 36L, 54L, 11L, 27L,
29L, 34L, 32L, 33L, 43L, 40L, 53L, 56L, 48L, 47L, 54L, 11L, 37L,
14L, 46L, 30L, 54L, 0L, 38L, 27L, 57L, 21L, 31L, 21L, 37L, 17L,
41L, 21L, 14L, 33L, 33L, 31L, 6L, 30L, 48L, 49L, 26L, 9L, 0L,
19L, 45L, 5L, 9L, 29L, 15L, 34L, 48L, 20L, 25L, 1L, 49L, 48L,
46L, 47L, 18L, 48L, 35L, 56L, 24L, 41L, 13L, 37L, 53L, 57L, 11L,
9L, 43L, 30L, 11L, 55L, 56L, 12L, 35L, 14L, 48L, 22L, 44L, 25L,
51L, 51L, 27L, 58L, 23L, 17L, 42L, 21L, 54L, 59L, 40L, 37L, 43L,
15L, 12L, 22L, 15L, 55L, 7L, 21L, 59L, 34L, 38L, 15L, 8L, 57L,
49L, 6L, 1L, 51L, 46L, 49L, 20L, 46L, 56L, 32L, 36L, 56L, 47L,
58L, 23L, 14L, 56L, 4L, 44L, 25L, 44L, 22L, 21L, 36L, 35L, 58L,
27L, 22L, 44L, 16L, 5L, 34L, 46L, 52L, 18L, 0L, 32L, 49L, 3L,
16L, 53L, 57L, 58L, 35L, 21L, 32L, 57L, 7L, 20L, 29L, 26L, 48L,
53L, 9L, 59L, 58L, 30L, 57L, 34L, 6L, 29L, 57L, 10L, 25L, 15L,
26L, 29L, 20L, 24L, 36L, 54L, 46L, 24L, 14L, 10L, 48L, 22L, 17L,
39L, 59L, 33L, 12L, 0L, 29L, 36L, 31L, 57L, 38L, 10L, 29L, 42L,
36L, 16L, 2L, 21L, 35L, 4L, 16L, 33L, 35L, 14L, 37L, 25L, 51L,
12L, 45L, 15L, 7L, 33L, 42L, 28L, 19L, 40L, 5L, 39L, 13L, 23L,
47L, 31L, 7L, 12L, 8L, 7L, 24L, 37L, 51L, 49L, 11L, 0L, 23L,
30L, 37L, 48L, 26L, 42L, 33L, 8L, 17L, 4L, 51L, 26L, 48L, 17L,
43L, 35L, 35L, 27L, 27L, 47L, 17L, 24L, 43L, 55L, 20L, 54L, 38L,
58L, 2L, 37L, 26L, 3L, 25L, 18L, 0L, 58L, 57L, 12L, 10L, 51L,
37L, 23L, 57L, 14L, 7L, 22L, 50L, 14L, 24L, 27L, 42L, 53L, 6L,
21L, 56L, 17L, 4L, 6L, 30L, 47L, 42L, 20L, 17L, 0L, 35L, 59L,
46L, 50L, 16L, 15L, 42L, 26L, 36L, 8L, 35L, 2L, 59L, 12L, 14L,
58L, 3L, 0L, 37L, 36L, 23L, 29L, 45L, 44L, 32L, 25L, 1L, 50L,
17L, 56L, 58L, 53L, 35L, 17L, 14L, 38L, 27L, 27L, 8L, 14L, 7L,
24L, 13L, 42L, 21L, 12L, 38L, 24L, 30L, 27L, 55L, 23L, 31L, 43L,
22L, 47L, 50L, 27L, 56L, 22L, 54L, 23L, 46L, 17L, 30L, 41L, 54L,
41L, 51L, 44L, 34L, 42L, 3L, 57L, 9L, 51L, 54L, 58L, 53L, 58L,
4L, 12L, 12L, 35L, 55L, 5L, 4L, 15L, 56L, 14L, 48L, 57L, 13L,
19L, 25L, 24L, 24L, 2L, 54L), hour = c(-3, -4, -3, -2, -4, -1,
-5, -4, -5, -5, -5, -4, -3, -2, -4, -2, -2, -4, -4, -1, -2, -5,
-5, -2, -2, -2, -5, -1, -1, -4, -3, -4, -4, -3, -4, -3, -1, -2,
-2, -1, -2, -5, -5, -3, -2, -2, -3, -3, -4, -1, -4, -3, -4, -2,
-5, -2, -4, -5, -4, -2, -5, -1, -5, -3, -2, -1, -3, -5, -1, -3,
-5, -1, -5, -1, -3, -1, -2, -5, -3, -1, -5, -1, -1, -3, -5, -1,
-2, -4, -4, -5, -3, -5, -4, -1, -5, -2, -5, -3, -5, -5, -2, -1,
-5, -3, -5, -3, -2, -4, -3, -1, -1, -2, -3, -1, -4, -3, -4, -5,
-1, -5, -3, -3, -1, -3, -3, -4, -4, -2, -5, -5, -1, -3, -5, -2,
-3, -2, -1, -5, -3, -5, -1, -1, -1, -3, -3, -5, -1, -2, -4, -2,
-4, -1, -4, -5, -1, -5, -1, -1, -4, -2, -5, -5, -3, -1, -5, -3,
-4, -5, -4, -5, -3, -5, -5, -5, -2, -5, -3, -5, -3, -4, -4, -5,
-5, -1, -4, -4, -1, -3, -1, -3, -3, -4, -2, -2, -4, -3, -1, -4,
-5, -3, -1, -3, -4, -3, -5, -1, -3, -5, -4, -5, -2, -4, -1, -3,
-5, -2, -5, -3, -4, -2, -5, -4, -1, -5, -3, -5, -1, -2, -2, -4,
-3, -4, -2, -4, -3, -4, -2, -5, -1, -1, -2, -1, -3, -5, -1, -1,
-2, -4, -4, -5, -3, -3, -3, -4, -4, -4, -4, -3, -4, -2, -5, -4,
-1, -4, -5, -4, -3, -3, -5, -2, -3, -1, -4, -1, -5, -2, -1, -1,
-4, -3, -2, -5, -4, -3, -4, -1, -3, -4, -5, -3, -2, -4, -1, -4,
-4, -2, -5, -3, -5, -1, -3, -4, -2, -1, -2, -3, -5, -3, -1, -1,
-3, -4, -4, -2, -2, -1, -2, -1, -4, -2, -5, -2, -1, -3, -5, -1,
-5, -3, -3, -5, -2, -1, -1, -4, -5, -5, -4, -1, -3, -5, -2, -4,
-1, -2, -4, -5, -5, -1, -5, -5, -4, -2, -5, -2, -3, -2, -2, -2,
-3, -2, -4, -4, -5, -1, -2, -5, -3, -1, -1, -4, -1, -5, -3, -5,
-4, -2, -4, -3, -4, -4, -3, -2, -2, -5, -2, -1, -1, -1, -3, -5,
-4, -5, -1, -1, -3, -2, -4, -2, -2, -1, -2, -4, -3, -5, -2, -1,
-4, -4, -1, -4, -2, -3, -2, -1, -5, -5, -4, -2, -1, -5, -3, -3,
-4, -5, -3, -4, -1, -3, -2, -2, -2, -4, -1, -2, -2, -2, -5, -1,
-4, -2, -4, -2, -5, -4, -2, -3, -2, -1, -1, -1, -3, -2, -5, -3,
-5, -2, -1), mday = c(24L, 30L, 13L, 17L, 11L, 17L, 1L, 26L,
21L, 1L, 9L, 6L, 7L, 17L, 17L, 4L, 24L, 23L, 31L, 2L, 22L, 19L,
12L, 17L, 26L, 13L, 12L, 26L, 14L, 20L, 22L, 14L, 26L, 29L, 7L,
16L, 19L, 10L, 19L, 17L, 15L, 22L, 4L, 22L, 6L, 22L, 6L, 24L,
18L, 11L, 13L, 26L, 5L, 2L, 1L, 12L, 15L, 21L, 22L, 24L, 25L,
18L, 4L, 18L, 28L, 4L, 21L, 25L, 18L, 4L, 8L, 10L, 21L, 11L,
11L, 20L, 23L, 14L, 16L, 2L, 31L, 3L, 21L, 3L, 1L, 13L, 26L,
20L, 17L, 4L, 3L, 13L, 10L, 23L, 16L, 1L, 28L, 27L, 16L, 29L,
6L, 15L, 6L, 14L, 4L, 17L, 15L, 4L, 19L, 26L, 20L, 22L, 24L,
1L, 16L, 18L, 12L, 21L, 26L, 11L, 30L, 19L, 26L, 4L, 3L, 2L,
26L, 30L, 14L, 16L, 21L, 20L, 29L, 26L, 17L, 23L, 8L, 19L, 23L,
14L, 14L, 5L, 28L, 6L, 15L, 13L, 8L, 6L, 1L, 2L, 3L, 5L, 16L,
17L, 3L, 23L, 20L, 27L, 28L, 1L, 31L, 26L, 14L, 30L, 22L, 9L,
31L, 5L, 19L, 9L, 27L, 26L, 24L, 12L, 27L, 20L, 9L, 4L, 9L, 4L,
18L, 9L, 13L, 10L, 23L, 27L, 11L, 21L, 6L, 6L, 6L, 9L, 23L, 14L,
27L, 23L, 17L, 19L, 29L, 16L, 18L, 4L, 5L, 29L, 14L, 16L, 19L,
25L, 14L, 16L, 27L, 12L, 11L, 26L, 2L, 17L, 1L, 20L, 2L, 3L,
5L, 7L, 27L, 27L, 17L, 6L, 4L, 11L, 5L, 15L, 13L, 19L, 1L, 29L,
18L, 29L, 17L, 23L, 31L, 26L, 19L, 17L, 14L, 21L, 17L, 13L, 5L,
13L, 4L, 27L, 13L, 18L, 4L, 24L, 23L, 21L, 25L, 25L, 2L, 24L,
25L, 28L, 6L, 10L, 15L, 9L, 7L, 8L, 9L, 22L, 17L, 11L, 15L, 24L,
14L, 23L, 18L, 28L, 3L, 20L, 25L, 5L, 17L, 21L, 24L, 21L, 24L,
3L, 31L, 21L, 18L, 27L, 30L, 25L, 13L, 8L, 21L, 16L, 22L, 24L,
3L, 16L, 4L, 22L, 15L, 30L, 2L, 16L, 28L, 24L, 26L, 20L, 9L,
3L, 3L, 4L, 11L, 5L, 30L, 19L, 24L, 3L, 24L, 5L, 14L, 4L, 23L,
18L, 7L, 16L, 24L, 3L, 27L, 4L, 30L, 22L, 28L, 17L, 25L, 3L,
19L, 18L, 26L, 8L, 24L, 18L, 17L, 6L, 17L, 25L, 6L, 23L, 14L,
4L, 5L, 15L, 5L, 4L, 19L, 4L, 7L, 24L, 28L, 23L, 28L, 9L, 7L,
27L, 26L, 25L, 4L, 19L, 24L, 18L, 18L, 7L, 16L, 11L, 10L, 21L,
6L, 30L, 15L, 1L, 16L, 16L, 21L, 17L, 8L, 19L, 1L, 23L, 10L,
18L, 2L, 8L, 20L, 28L, 25L, 28L, 25L, 23L, 5L, 4L, 31L, 2L, 21L,
30L, 1L, 4L, 18L, 8L, 25L, 1L, 25L, 2L, 5L, 20L, 2L, 17L, 5L,
5L, 30L, 30L, 17L, 5L, 18L, 21L, 24L, 20L, 26L, 31L, 15L, 30L,
16L, 6L, 18L, 28L, 7L, 25L, 24L, 7L, 23L, 9L, 8L, 25L, 11L, 20L,
19L, 24L, 5L, 5L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, 9L, 4L, 8L, 9L, 9L, 10L,
10L, 3L, 7L, 9L, 4L, 8L, 2L, 10L, 10L, 4L, 3L, 1L, 9L, 7L, 9L,
3L, 5L, 0L, 8L, 9L, 7L, 8L, 5L, 7L, 8L, 8L, 10L, 1L, 7L, 2L,
9L, 8L, 2L, 5L, 0L, 10L, 5L, 6L, 2L, 10L, 1L, 8L, 7L, 0L, 1L,
3L, 9L, 3L, 6L, 4L, 10L, 0L, 3L, 5L, 4L, 10L, 9L, 7L, 4L, 3L,
0L, 3L, 3L, 1L, 9L, 5L, 3L, 3L, 8L, 11L, 10L, 4L, 11L, 0L, 7L,
1L, 0L, 4L, 2L, 2L, 0L, 0L, 7L, 4L, 4L, 10L, 8L, 3L, 8L, 11L,
8L, 0L, 0L, 6L, 6L, 1L, 0L, 3L, 4L, 2L, 9L, 1L, 6L, 4L, 3L, 1L,
0L, 0L, 11L, 1L, 4L, 3L, 7L, 10L, 2L, 1L, 0L, 0L, 5L, 4L, 8L,
10L, 7L, 10L, 8L, 8L, 1L, 8L, 11L, 8L, 10L, 7L, 11L, 4L, 8L,
1L, 10L, 3L, 10L, 5L, 10L, 7L, 9L, 9L, 2L, 10L, 0L, 9L, 4L, 7L,
7L, 11L, 1L, 11L, 1L, 1L, 4L, 2L, 3L, 3L, 5L, 10L, 0L, 7L, 9L,
7L, 10L, 10L, 4L, 2L, 0L, 0L, 1L, 7L, 8L, 6L, 9L, 9L, 11L, 4L,
6L, 8L, 9L, 0L, 8L, 6L, 4L, 6L, 7L, 4L, 0L, 0L, 9L, 1L, 4L, 0L,
1L, 8L, 1L, 3L, 7L), year = c(112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L
), wday = c(6L, 3L, 1L, 5L, 5L, 6L, 6L, 2L, 4L, 5L, 4L, 3L, 3L,
3L, 5L, 3L, 5L, 4L, 2L, 6L, 3L, 1L, 4L, 4L, 6L, 5L, 3L, 1L, 5L,
5L, 0L, 2L, 2L, 0L, 5L, 0L, 6L, 0L, 1L, 1L, 0L, 2L, 6L, 3L, 4L,
0L, 2L, 1L, 3L, 6L, 0L, 4L, 5L, 1L, 2L, 1L, 0L, 0L, 5L, 5L, 2L,
6L, 3L, 3L, 1L, 3L, 5L, 2L, 6L, 5L, 6L, 3L, 4L, 5L, 3L, 5L, 4L,
6L, 4L, 5L, 1L, 4L, 2L, 5L, 1L, 6L, 5L, 2L, 2L, 6L, 3L, 5L, 0L,
0L, 1L, 4L, 3L, 5L, 0L, 0L, 6L, 4L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, 4L, 5L, 6L, 5L, 6L, 1L, 5L,
4L, 1L, 5L, 0L, 0L, 0L, 0L, 2L, 3L, 1L, 1L, 0L, 0L, 5L, 3L, 4L,
0L, 3L, 6L, 0L, 0L, 3L, 5L, 6L, 6L, 6L, 4L, 6L, 3L, 5L, 5L, 2L,
2L, 4L, 0L, 0L, 5L, 4L, 4L, 4L, 4L, 2L, 0L, 3L, 2L, 6L, 3L, 5L,
4L, 3L, 1L, 2L, 2L, 1L, 5L, 5L, 0L, 5L, 5L, 4L, 1L, 3L, 6L, 5L,
1L, 3L, 2L, 1L, 2L, 0L, 0L, 3L, 5L, 0L, 3L, 1L, 6L, 3L, 1L, 3L,
5L, 3L, 5L, 5L, 5L, 6L, 4L, 0L, 3L, 2L, 0L, 3L), yday = c(328L,
150L, 225L, 229L, 131L, 321L, 335L, 177L, 172L, 152L, 39L, 157L,
311L, 290L, 47L, 185L, 236L, 235L, 30L, 153L, 234L, 323L, 193L,
137L, 146L, 194L, 346L, 330L, 257L, 110L, 203L, 44L, 177L, 210L,
341L, 259L, 139L, 161L, 78L, 260L, 14L, 142L, 34L, 52L, 340L,
21L, 65L, 358L, 199L, 41L, 133L, 207L, 278L, 183L, 121L, 316L,
14L, 294L, 173L, 54L, 268L, 48L, 185L, 199L, 148L, 94L, 264L,
359L, 230L, 124L, 342L, 283L, 172L, 131L, 192L, 19L, 235L, 13L,
46L, 306L, 365L, 123L, 233L, 215L, 274L, 286L, 299L, 324L, 107L,
34L, 276L, 103L, 161L, 357L, 197L, 305L, 332L, 26L, 350L, 119L,
279L, 319L, 187L, 257L, 155L, 229L, 227L, 247L, 49L, 299L, 79L,
356L, 54L, 182L, 228L, 322L, 71L, 264L, 269L, 254L, 273L, 139L,
56L, 3L, 2L, 153L, 207L, 211L, 104L, 167L, 233L, 232L, 363L,
207L, 47L, 266L, 312L, 292L, 82L, 318L, 318L, 4L, 118L, 279L,
288L, 225L, 220L, 36L, 274L, 61L, 62L, 4L, 228L, 16L, 215L, 327L,
232L, 178L, 240L, 152L, 243L, 360L, 134L, 334L, 234L, 343L, 212L,
339L, 323L, 190L, 86L, 207L, 23L, 224L, 331L, 79L, 282L, 124L,
39L, 63L, 230L, 252L, 103L, 314L, 327L, 270L, 10L, 294L, 96L,
340L, 187L, 343L, 174L, 73L, 270L, 82L, 351L, 353L, 59L, 259L,
48L, 185L, 248L, 149L, 134L, 106L, 49L, 55L, 257L, 320L, 239L,
102L, 254L, 177L, 122L, 47L, 213L, 232L, 183L, 62L, 186L, 280L,
208L, 361L, 260L, 187L, 308L, 70L, 35L, 227L, 194L, 323L, 152L,
149L, 48L, 28L, 47L, 22L, 365L, 85L, 200L, 290L, 348L, 355L,
321L, 347L, 217L, 256L, 124L, 208L, 286L, 138L, 247L, 297L, 296L,
325L, 329L, 115L, 214L, 297L, 145L, 271L, 65L, 314L, 319L, 129L,
97L, 38L, 282L, 234L, 290L, 101L, 166L, 23L, 257L, 296L, 230L,
271L, 154L, 232L, 268L, 248L, 321L, 51L, 236L, 80L, 297L, 246L,
90L, 172L, 17L, 331L, 181L, 206L, 72L, 312L, 51L, 259L, 234L,
23L, 33L, 106L, 277L, 112L, 196L, 150L, 306L, 15L, 118L, 175L,
146L, 324L, 282L, 215L, 123L, 94L, 10L, 95L, 120L, 49L, 297L,
154L, 114L, 95L, 257L, 338L, 327L, 138L, 341L, 15L, 236L, 33L,
26L, 124L, 89L, 81L, 27L, 16L, 237L, 123L, 139L, 322L, 269L,
98L, 267L, 352L, 260L, 5L, 16L, 206L, 187L, 53L, 13L, 94L, 125L,
74L, 278L, 34L, 200L, 124L, 97L, 54L, 27L, 22L, 362L, 39L, 127L,
117L, 238L, 329L, 63L, 49L, 23L, 17L, 169L, 127L, 259L, 315L,
222L, 325L, 249L, 273L, 45L, 244L, 350L, 259L, 325L, 229L, 342L,
139L, 244L, 53L, 314L, 108L, 306L, 159L, 324L, 240L, 298L, 301L,
84L, 327L, 4L, 277L, 151L, 214L, 233L, 364L, 31L, 338L, 48L,
38L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yday", "isdst"
), class = c("POSIXlt", "POSIXt"))
Then, trying to extract hours in different ways
df <- data.frame(times,
with.dollar = times$hour,
with.format = as.numeric(format(times, "%H"))
)
head(df)
and my results are
times with.dollar with.format
1 2012-11-23 21:05:00 -3 21
2 2012-05-29 20:43:00 -4 20
3 2012-08-12 21:02:00 -3 21
4 2012-08-16 22:47:00 -2 22
5 2012-05-10 20:15:00 -4 20
6 2012-11-16 23:18:00 -1 23
Another test (not in a data.frame... simple vectors)
> any(times$hour == as.numeric(format(times, "%H")))
[1] FALSE
With times$hour it seems to be counting hours starting from the next days in some cases (all of the cases here reported).
Could you reproduce that? any idea why?
Looking at ?POSIXlt this could be a bug because not all hours are within 0:23 range.
If so, for the moment it would be safer to use format rather $ for POSIXlt vector
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 0.3
year 2014
month 03
day 06
svn rev 65126
language R
version.string R version 3.0.3 (2014-03-06)
nickname Warm Puppy

Counting then sum particular values?

I have a data as below ( just a part of my data)
month NumberOfMonths
Jan 4
Jan 3
Feb 2
May 1
Jan 4
Feb 1
May 2
Mar 12
Feb 2
May 1
So I want to create a data frame as below
Month NumberOfMonths
1 2 3 4 5 6 7 8 9 10 11 12
Jan 0 0 1 2 0 0 0 0 0 0 0 0
Feb 1 2 0 0 0 0 0 0 0 0 0 0
Mar 0 0 0 0 0 0 0 0 0 0 0 1
Apr 0 0 0 0 0 0 0 0 0 0 0 0
May 2 1 0 0 0 0 0 0 0 0 0 0
As you see above, the function will count the same number of month and will assign to corresponding month. For example, if i have two 4 in NumberOfMonths, in my data frame january for NumberOfMonths 4 will be 2.
By the way class of Month is factor not date.
can anyone help me please?
I tried every function all you gave. However, I could not get the same result. I pasted my data output. If you wouldn't mind my can you help again?
structure(list(Month = structure(c(4L, 5L, 5L, 12L, 5L, 5L, 2L,
12L, 11L, 10L, 7L, 9L, 7L, 4L, 8L, 7L, 5L, 12L, 12L, 5L, 5L,
5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L, 6L, 1L, 2L, 5L, 9L, 4L, 6L, 5L, 5L,
8L, 11L, 5L, 8L, 7L, 12L, 7L, 6L, 8L, 9L, 9L, 6L, 11L, 12L, 5L,
4L, 4L, 1L, 1L, 5L, 5L, 2L, 4L, 9L, 4L, 1L, 1L, 8L, 1L, 1L, 5L,
2L, 8L, 6L, 1L, 9L, 5L, 10L, 6L, 2L, 12L, 5L, 5L, 10L, 5L, 8L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 9L, 7L, 5L, 12L, 11L, 7L,
5L, 5L, 5L, 12L, 11L, 11L, 10L, 5L, 5L, 5L, 12L, 12L), .Label = c("Apr",
"Aug", "Dec", "Feb", "Jan", "Jul", "Jun", "Mar", "May", "Nov",
"Oct", "Sep"), class = "factor"), NumberOfMonth = c(1, 12.0000000000009,
1, 1, 12.0000000000009, 12.0000000000009, 1, 1.99999999999909,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3.00000000000091,
3.00000000000091, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10.9999999999991,
1, 1, 1, 1, 1.99999999999909, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1,
3.00000000000091, 1, 4, 12.0000000000009, 1, 1, 12.0000000000009,
12.0000000000009, 12.0000000000009, 4, 1, 12.0000000000009, 12.0000000000009,
1, 12.0000000000009, 1, 7.99999999999909, 4, 12.0000000000009,
1, 1, 4, 4, 12.0000000000009, 1, 1.99999999999909, 1, 1, 1, 1.99999999999909,
1, 1, 1, 1, 1, 1, 1, 1.99999999999909, 1, 1, 1, 1, 1, 1, 1, 12.0000000000009,
1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 4, 7, 12.0000000000009, 1, 1,
1, 12.0000000000009, 1, 12.0000000000009, 12.0000000000009, 1,
12.0000000000009, 4.99999999999909, 6.00000000000091, 1, 10.9999999999991,
1, 1.99999999999909, 1, 2.99999999999818, 1, 1, 1, 1, 4, 1.99999999999909,
12.0000000000009, 12.0000000000009, 12.0000000000009, 1.99999999999909,
4, 4, 12.0000000000009, 1, 2.99999999999818, 1, 1, 2.00000000000182,
4, 1, 7, 12.0000000000009, 1, 1, 6.00000000000091, 1, 7, 4, 3.00000000000091,
1, 1, 1, 1, 1, 1, 1.99999999999909, 1, 1, 16, 12.0000000000009,
1, 12.0000000000009, 12.0000000000009, 1, 12.0000000000009, 1,
1, 12.0000000000009, 1, 12.0000000000009, 7, 3.00000000000091,
1, 1, 1.99999999999909, 4.99999999999909, 12.0000000000009, 1.99999999999909,
1.99999999999909, 6.00000000000091, 1, 7, 1, 1, 1.99999999999909,
1, 1, 4, 3.00000000000091, 1.99999999999909, 1, 1, 3.00000000000091,
1, 1, 1, 12.0000000000009, 1, 1, 1, 12.0000000000009, 10.9999999999991,
1, 1, 2.00000000000182, 1, 1, 1, 12.0000000000009, 1, 1, 12.0000000000009,
12.0000000000009, 24.0000000000009, 1, 1, 12.0000000000009, 1,
1, 1, 10, 12.0000000000009, 1, 4, 12.0000000000009, 1.99999999999909,
1, 7.99999999999909, 12.0000000000009, 12.0000000000009, 12.0000000000009,
12.0000000000009, 12.0000000000009, 12.0000000000009, 6.00000000000091,
12.0000000000009, 12.0000000000009, 4, 1, 1, 1, 12.0000000000009,
1, 1, 2.00000000000182, 12.0000000000009, 12.0000000000009, 1,
6.00000000000091, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2.99999999999818,
1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 2.00000000000182, 12.0000000000009,
12.0000000000009, 1, 1, 12.0000000000009, 1, 4.99999999999909,
12.0000000000009, 7.99999999999909, 1, 1, 1, 21.0000000000009,
7, 9.00000000000091, 2.00000000000182, 4, 4, 3.00000000000182,
12.0000000000009, 1, 1, 12.0000000000009, 1, 1, 4.99999999999909,
1, 1, 1.99999999999909, 1, 4.99999999999909, 4.99999999999909,
4.99999999999909, 4.99999999999909, 4.99999999999909, 1, 1, 1,
1, 1, 1, 1, 1, 1, 4, 1, 3.00000000000091, 12.0000000000009, 1,
1, 12.0000000000009, 12.0000000000009, 6.00000000000091, 3.00000000000091,
4, 1, 12.0000000000009, 7, 3.00000000000091, 1.99999999999909,
1, 1, 1, 1, 12.0000000000009, 1, 24.0000000000009, 12.0000000000009,
1, 12.0000000000009, 12.0000000000009, 12.0000000000009, 1, 1,
1, 1, 10.9999999999991, 1, 1.99999999999909, 1, 10.9999999999991,
3.00000000000091, 6.00000000000091, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 7, 1, 1, 4, 12.0000000000009, 4, 4, 12.0000000000009, 12.0000000000009,
12.0000000000009, 12.0000000000009, 6.00000000000091, 1.99999999999909,
1, 1, 1, 4.99999999999909, 12.0000000000009, 1, 1, 1, 12.0000000000009,
12.0000000000009, 12.0000000000009, 1, 1, 1, 1, 10.9999999999991,
12.0000000000009, 1, 1, 1, 1, 1, 7.99999999999909, 4, 2.99999999999818,
1.99999999999909, 1, 1, 4, 4, 1, 12.0000000000009, 12.0000000000009,
1.99999999999909, 1, 1, 1, 1, 12.0000000000009, 1.99999999999909,
4.99999999999909, 4.99999999999909, 3.00000000000091, 4, 1, 1,
1, 1, 2.00000000000182, 1, 1.99999999999909, 1, 3.00000000000091,
12.0000000000009, 4, 1.99999999999909, 9.00000000000091, 10,
1, 1, 1, 1, 12.0000000000009, 4, 2.00000000000182, 3.00000000000091,
4, 1, 1, 1, 1, 1, 4.99999999999909, 1.99999999999909, 1.99999999999909,
7, 1, 4, 1, 7, 7.99999999999909, 12.0000000000009, 1, 10, 1,
12.0000000000009, 7.99999999999909, 1, 1, 12.0000000000009, 4,
7.99999999999909, 7, 2.99999999999818, 1, 3.00000000000091, 4.99999999999909,
1, 1, 4, 4.99999999999909, 1, 6.00000000000091, 5.99999999999818,
1, 9.00000000000091, 1, 7.99999999999909, 1, 1, 1, 4.99999999999909,
1, 1, 1, 1, 1, 4.99999999999909, 1, 1, 1, 1, 1, 10.9999999999991,
1, 1, 1, 1, 2.00000000000182, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 4.99999999999909, 1, 1, 1, 1, 9.00000000000091, 1.99999999999909,
1, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 1, 1, 1.99999999999909,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7.99999999999909, 1, 1.99999999999909,
1, 1, 1, 1, 1, 1, 1, 1, 12.0000000000009, 12.0000000000009, 1,
12.0000000000009, 1, 1.99999999999909, 1, 1, 12.0000000000009,
10, 12.0000000000009, 1, 1, 1, 1, 10, 12.0000000000009, 1, 1,
1, 12.0000000000009, 12.0000000000009, 12.0000000000009, 1, 1,
1, 1, 12.0000000000009, 12.0000000000009, 12.0000000000009, 1,
1)), .Names = c("Month", "NumberOfMonth"), 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, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L,
161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L,
172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L,
183L, 184L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L,
194L, 195L, 196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L,
205L, 206L, 207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L,
216L, 217L, 218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L,
227L, 228L, 229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L,
238L, 239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L,
249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L,
260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L,
271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L,
282L, 283L, 284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L,
293L, 294L, 295L, 296L, 297L, 298L, 299L, 300L, 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, 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, 444L, 445L, 446L, 447L, 448L, 449L,
450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 459L, 460L,
461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 469L, 470L, 471L,
472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L, 480L, 481L, 482L,
483L, 484L, 485L, 486L, 487L, 488L, 489L, 490L, 491L, 492L, 493L,
494L, 495L, 496L, 497L, 498L, 499L, 500L, 501L, 502L, 503L, 504L,
505L, 506L, 507L, 508L, 509L, 510L, 511L, 512L, 513L, 514L, 515L,
516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L,
527L, 528L, 529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L,
538L, 539L, 540L, 541L, 542L, 543L, 544L, 545L, 546L, 547L, 548L,
549L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 558L, 559L,
560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, 569L, 570L,
571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, 580L, 581L,
582L, 583L, 584L, 585L, 586L, 587L, 588L, 589L, 590L, 591L, 592L,
593L, 594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L, 603L,
604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L, 614L,
615L, 616L, 617L, 618L, 619L), class = "data.frame", na.action = structure(c(349L,
442L, 443L), .Names = c("349", "442", "443"), class = "omit"))
Read in the data
dd = read.table(textConnection("month NumberOfMonths
Jan 4
Jan 3
Feb 2
May 1
Jan 4
Feb 1
May 2
Mar 12
Feb 2
May 1"), header=TRUE)
Set up a factor with correct levels
dd$month = factor(dd$month, levels=month.abb)
## I've made No. of months a factor to influence the table output
dd$NumberOfMonths = factor(dd$NumberOfMonths, levels=1:12)
Now tabulate
table(dd$month, dd$NumberOfMonths)
## Drop unused months
table(droplevels(dd$month), droplevels(dd$NumberOfMonths))
you also have xtabs :
tab$NumberOfMonths <- factor(tab$NumberOfMonths, levels=1:12)
tab$month <- factor(tab$month, levels=c("Jan", "Feb", "Mar", "Apr", "May"))
xtabs(~month+NumberOfMonths, data=tab)
I also like using the dcast function within the reshape2 package.
dat <- ...
dcast(dat, month ~ NumberOfMonths)
# month 1 2 3 4 12
#1 Feb 1 2 0 0 0
#2 Jan 0 0 1 2 0
#3 Mar 0 0 0 0 1
#4 May 2 1 0 0 0

Apply function to data grouped by cut()

I would like some help with summarising data using cut. I have been successful in less complicated situations, but now I am stuck.
The data:
> dput(sumsq)
structure(list(part_no = c(10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,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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), diffdist = c(-9L, -7L, -16L,
-17L, -38L, 55L, -17L, -2L, -18L, -24L, -7L, 24L, -40L, -35L,
69L, -42L, -15L, 80L, 73L, -28L, 39L, -46L, 40L, -49L, 11L, -9L,
-6L, -50L, 71L, 23L, -69L, -1L, 8L, 37L, -29L, -16L, 25L, -8L,
-44L, 27L, -20L, -11L, 16L, -16L, 40L, -57L, -13L, 13L, 40L,
-7L, 51L, -19L, -2L, -9L, 22L, 35L, -13L, -20L, -4L, -64L, 0L,
-48L, -55L, -19L, 20L, 6L, 31L, 9L, -62L, -4L, -50L, 39L, 53L,
-22L, 33L, 58L, 62L, -37L, 5L, -5L, 36L, 35L, -9L, 16L, -42L,
-20L, 7L, 24L, 29L, -80L, 41L, -18L, -28L, -16L, 6L, 15L, -37L,
52L, -12L, -40L, 64L, -28L, 22L, 29L, -4L, -47L, -3L, -61L, -2L,
21L, 3L, 9L, 35L, 73L, -20L, -8L, -53L, -19L, -11L, -6L, -56L,
17L, -20L, -66L, -16L, -29L, 26L, -29L, 44L, 38L, 40L, 51L, 84L,
-33L, -33L, -6L, -71L, -14L, -13L, -47L, 21L, 5L, -9L, -42L,
-26L, 35L, 53L, 2L, -6L, 31L, -22L, -70L, -17L, 35L, -55L, 9L,
-14L, 2L, 11L, -71L, 49L, 30L, -40L, -77L, 15L, 53L, -29L, 51L,
68L, -5L, -24L, -75L, -60L, -27L, -43L, -5L, -3L, -31L, -22L,
8L, -43L, 9L, -43L, -35L, 70L, -47L, -23L, 25L, -64L, 0L, -24L,
-17L, 68L, -12L, -57L, 28L, -9L, 42L, 35L, 21L, 13L, 9L, -9L,
-12L, 31L, -6L, -8L, -33L, 20L, -4L, -53L, 37L, -33L, 21L, 68L,
-28L, -56L, 61L, -69L, -12L, 9L, -23L, -60L, -9L, -7L, 45L, -44L,
-33L, 47L, -7L, 53L, -2L, -13L, -18L, 57L, -2L, 45L, 40L, -18L,
9L, -21L, 22L, 4L, 27L, 27L, -63L, -62L, -59L, 13L, -3L, -62L,
2L, 23L, 52L, 20L, -18L, 52L, 40L, -51L, -24L, -18L, -29L, -47L,
-33L, 64L, -74L, -36L, 18L, -36L, 22L, 8L, -46L, 24L, 4L, -74L,
-3L, 18L, -53L, 20L, 60L, -9L, -19L, 15L, 31L, 18L, 35L, 24L,
11L, -40L, -64L, 33L, -31L, 8L, 58L, 41L, -33L, -53L, -35L, 2L,
-19L, 42L, -53L, 64L, 46L, -53L, 62L, -77L, -18L, -3L, -11L,
33L, -67L, 68L, 0L, 51L, 13L, -11L, 40L, -65L, 22L, 39L, -5L,
76L, -44L, -35L, 15L, 0L, 13L, 7L, 6L, -51L, -44L, -20L, 20L,
11L, -55L, -66L, -49L, 4L, -58L, -27L, 20L, -16L, 42L, -69L,
71L, -68L, -42L, 44L, 31L, -13L, -63L, -72L, -13L, 19L, 39L,
-13L, 71L, -53L, -33L, 67L, -42L, 14L, 39L, 33L, -13L, -19L,
73L, -71L, -24L, 11L, 0L, -42L, -71L, -1L, -62L, -11L, -7L, 18L,
49L, 8L, -21L, -5L, 13L, -38L, 62L, -15L, -27L, 0L, -33L, 9L,
-40L, -57L, 60L, 73L, -24L, 0L, 22L, -37L, -46L, -27L, 27L, 0L,
6L, 77L, -13L, 47L, 71L, -20L, 11L, 18L, 31L, 8L, 80L, -87L,
-20L, 57L, -37L, 24L, 62L, -11L, -50L, 9L, 52L, 7L, 2L, -57L,
-50L, 69L, 7L, -42L, -43L, -22L, 46L, 57L, 24L, 35L, 9L, -54L,
51L, 6L, -8L, -8L, 9L, 48L, 24L, 31L, -55L, 53L, 44L, 7L, -7L,
22L, -53L, 42L, -44L, -2L, 6L, -9L, -5L, 33L, -20L, 20L, 36L,
39L, -16L, -25L, 44L, -28L, 4L, -4L, -47L, -87L, 6L, -38L, 51L,
-9L, 37L, -47L, 72L, -19L, 26L, 37L, -43L, 29L, -11L, 54L, 4L,
-41L, -24L, -55L, 11L, 35L, 22L, 57L, 61L, 40L, -52L, -17L, 10L,
28L, -24L, -28L, -3L, -9L, -47L, 40L, 35L, 57L, 13L, 13L, 33L,
24L, 22L, -67L, -49L, -77L, 7L, -36L, 9L, 29L, -16L, -5L, 11L,
-13L, 57L, -17L, 49L, 66L, -55L, -33L, -6L, -29L, 5L, -62L, 80L,
33L, 73L, 87L, -3L, 18L, 40L, 18L, 70L, 49L, 55L, 5L, -13L, 9L,
-17L, 36L, -22L, 9L, 0L, -75L, -40L, -12L, 17L, 19L, -9L, 13L,
-15L, -51L, 10L, -20L, 1L, 3L, 40L, 38L, 19L, 11L, 0L, 89L, -10L,
49L, 44L, 75L, 83L, -8L, 36L, -60L, 38L, -53L, -19L, 11L, 4L,
-53L, -51L, -11L, 71L, 20L, 7L, -33L, 37L, 3L, 49L, 22L, -57L,
-74L, -30L, 22L, 11L, -9L, -19L, -51L, -42L, 3L, 55L, -42L, -7L,
-19L, -53L, 32L, -73L, 11L, -9L, -31L, 20L, -5L, 55L, -26L, -22L,
-28L, 75L, -15L, -58L, 20L, 37L, -26L, -57L, -50L, -47L, -35L,
-20L, 22L, 1L, 28L, 0L, -38L, 24L, 40L, 22L, -33L, 34L, -28L,
-18L, 33L, -57L, 4L, -13L, -25L, -62L, 33L, -62L, 55L, 28L, -9L,
14L, -50L, -18L, -40L, 20L, 24L, -53L, -27L, 23L, 4L, 13L, 27L,
-55L, -4L, 44L, 4L, -9L, -17L, -44L, -42L, 18L, -33L, -44L, 17L,
-53L, -13L, -24L, -56L, -41L, 28L, 31L, 21L, -13L, 27L, -46L,
-50L, -25L, 29L, -7L, -6L, -11L, -18L, 71L, -69L, -50L, -3L,
2L, 18L, -24L, -40L, -15L, -46L, 11L, 29L, 10L, -30L, 7L, -13L,
50L, 77L, 2L, 9L, -71L, -9L, -62L, -55L, 29L, 38L, -48L, -22L,
-30L, 39L, -44L, 42L, -5L, -61L, 16L, 24L, -46L, 2L, 4L, -8L,
-16L, 33L, -35L, 80L, -39L, 19L, -55L, -23L, -46L, 2L, 7L, -77L,
-5L, 18L, -44L, -18L, -62L, -62L, -84L, 85L, 13L, 49L, 11L, 41L,
40L, -38L, 15L, 39L, -13L, 39L, -11L, -64L, 58L, 35L, -18L, 34L,
18L, 24L, -22L, -4L, -46L, -71L, 22L, -44L, -49L, -11L, -40L,
-4L, 11L, -5L, 37L, -24L, -27L, -33L, 52L, -11L, 9L, -54L, 0L,
-24L, 0L, 18L, 13L, -17L, 22L, 64L, 58L, 71L, -6L, -24L, 29L,
-3L, -22L, -9L, 55L, -9L, -16L, -35L, 56L, 25L, -58L, -26L, -9L,
62L, -48L, -62L, 9L, 35L, -8L, 33L, 40L, 55L, 40L, 35L, -23L,
11L, 46L, 62L, -15L, -2L, -9L, -17L, 39L, 15L, -13L, -37L, 20L,
-7L, -14L, 70L, 28L, -2L, 55L, -25L, 6L, -36L, 30L, 62L, 66L,
11L, 24L, -42L, 58L, 9L, 45L, 4L, 0L, -20L, 20L, 27L, -4L, 3L,
-40L, -2L, 2L, 10L, 8L, 20L, -24L, -39L, -13L, 20L, -45L, -76L,
-46L, 3L, -55L, -18L, 22L, 2L, -14L, -20L, -26L, 51L, -66L, -9L,
0L, 51L, 22L, -12L, 27L, -35L, 11L, 38L, -3L, 15L, 4L, -55L,
44L, -55L, -46L, 6L, -46L, 22L, 22L, 46L, 20L, 35L, -11L, -20L,
-53L, 51L, -80L, -59L, -53L, -78L, -36L, -13L, 31L, 33L, -9L,
-26L, 31L, -14L, -16L, -15L, -53L, 9L, 65L, 3L, 44L, -42L, 45L,
-13L, -7L, -6L, 52L, 60L, -3L, -3L, 7L, -40L, 2L, 29L, 11L, 33L,
40L, -16L, -9L, -21L, 78L, -60L, 15L, 0L, 17L, -15L, -18L, 48L,
26L, 31L, -53L, -9L, -3L, -1L, 64L, 7L, 44L, -38L, -23L, 13L,
55L, 57L, -71L, -20L, 23L, -18L, 4L, 16L, -7L, 52L, 42L, 24L,
5L, -2L, 6L, -33L, 9L, 30L, -51L, 58L, 53L, -44L, -22L, -44L,
-75L, -60L, 46L, 14L, 13L, -5L, -7L, 69L, -18L, 53L, 52L, -62L,
-13L, 22L, 64L, -18L, 71L, 24L, -9L, 68L, -40L, -10L, -2L, 12L,
37L, 40L, 79L, 3L, 42L, -55L, 7L, -31L, 20L, 16L, 7L, 11L, -14L,
70L, 24L, 3L, -57L, -14L, 51L, -19L, -62L, -16L, -2L, -68L, 4L,
7L, -20L, 4L, -15L, 49L, -16L, 11L, 6L, 56L, -6L, 68L, 28L, 33L,
-62L, 20L, -39L, -12L, -45L, -30L, -15L, 37L, 44L, 39L, 38L,
46L, 33L, 2L, -3L, 29L, 44L, 2L, -57L, 37L, 42L, 20L, 5L, 53L,
-51L, 11L, -5L, -24L, 7L, 29L, -20L, -15L, 24L, 80L, 4L, 82L,
29L, -24L, 68L, -38L, 27L, 71L, 30L, 42L, 14L, -75L, -41L, 22L,
46L, -72L, -53L, 78L, 54L, 22L, -55L, 57L, -1L, -54L, 80L, 68L,
-17L, -18L, -3L, 5L, 16L, -39L, -21L, -29L, -64L, -5L, 46L, -8L,
3L, -15L, 26L, -6L, 38L, -2L, -13L, -62L, -51L, -60L, 9L, -64L,
51L, 31L, 36L, 0L, -35L, 29L, 22L, 31L, -2L, 14L, 73L, -17L,
17L, -58L, 55L, 37L, -16L, 71L, 28L, 72L, -26L, 22L, 12L, 25L,
23L, -46L, -9L, -55L, -7L, 18L, -40L, 28L, -9L, 5L, -6L, 26L,
58L, 31L, -38L, -27L, 14L, -34L, -5L, 9L, 20L, -35L, 31L, -3L,
-19L, -33L, 34L)), .Names = c("part_no", "ratperc", "diffdist"
), 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")
using the vector:
timevec1 = as.vector(ggplot2:::breaks(sumsq$diffdist, "n", n=8))
I normally summarise the data using xtabs and cutusing:
bb1 = data.frame(xtabs(~ratperc +cut(diffdist, timevec1 ), dat=sumsq))
colnames(bb1) = c("rating", "range", "freq", "id")
While this solution is not idea for what I wanted it, I was able to then summarise the values for each cut using ddply.
However now I need to preserve the part_no too, but I can't seem to be able to pass more than one column to cut.
The question is, is there any way to do everything in one step? Basically get for each participant the mean of all the ratings for each cut? In other words, part_no as rows, ranges as columns and the intersection being the mean of ratings for the values that below there.
If you just want the mean rating for each part_no and interval from cut(diffdist, timevec1 ) I would just do something like this:
#Add cut variable as new column
sumsq$range <- cut(sumsq$diffdist,timevec1)
#Summarise using ddply
ddply(sumsq,.(part_no,range),summarise,val = mean(ratperc))
I didn't get if you want the mean for each participant and interval or the cumulative mean along the intervals for each participant.
If you want the normal mean you can get it with
sapply(split(sumsq, cut(sumsq$diffdist, timevec1)), function(ss)
sapply(split(ss$ratperc, ss$part_no), mean))
If you want the cumulative you can rephrase it as
t(sapply(split(sumsq, sumsq$part_no), function(ss){
sapply(timevec1[-1], function(tc) mean(ss$ratperc[ss$diffdist <= tc]))
}))

Resources