我在哪里错了这些数据。
我正在尝试group_by
并计算DOLLARS.x
列的总和,但是当我想要每个PANID
的结果时,我只会得到1个结果。
dat %>%
group_by(datetime, PANID) %>%
summarise(total = sum(DOLLARS.x))
数据:
df <- structure(list(datetime = structure(c(1198584660, 1198584660,
1198752840, 1199106060, 1198917840, 1199106060, 1198917840, 1198851120,
1198758360, 1198758360, 1198925880, 1199091420, 1199091420, 1199091420,
1198766040, 1198876140, 1198837140, 1198593480, 1198837140, 1198593480,
1198837140, 1198593480, 1198837140, 1198593480, 1198662900, 1198662900,
1198662900, 1198662900, 1199096220, 1199021400, 1198586880, 1199024280,
1198586880, 1199024280, 1199017140, 1199017140, 1199017140, 1199017140,
1199017140, 1199017140, 1199017140, 1198948620, 1198948620, 1198948620,
1199102340, 1198663560, 1199011440, 1198745580, 1199011740, 1198770540,
1199011740, 1198770540, 1198848900, 1198683660, 1198762320, 1198852800,
1198767060, 1199112660, 1198595100, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198935780, 1198931940, 1198679760,
1198671240, 1198942800, 1199115420, 1198751400, 1198849260, 1198588800,
1199112300, 1199094960, 1199119860, 1198861260, 1199119860, 1198861260,
1199119860, 1198861260, 1199119860, 1198861260, 1198763460, 1198942560,
1198942560, 1198760460, 1199007120, 1199007120, 1198852920, 1198933500,
1198674600, 1199119320, 1198936500, 1198770180, 1199109660, 1198919880,
1198744560, 1199093820, 1199107080, 1198924500, 1198924500, 1198924500,
1198924500, 1198832940, 1198832940, 1198858500, 1198941360, 1198745460,
1198679280, 1198587240, 1198587240, 1198587240, 1199111880, 1198756560,
1199018280, 1198850880, 1199002200, 1199002200, 1198846680, 1199091840,
1199091840, 1199099940, 1199099940, 1198846740, 1198846740, 1198846740,
1198840620, 1199107440, 1199107440, 1198580640, 1198761840, 1198580640,
1198761840, 1199091600, 1199091600, 1198840140, 1198840140, 1198924020,
1198844460, 1198779060, 1198779060, 1198859520, 1199100480, 1198599720,
1198946220, 1198938480, 1198755000, 1199099400, 1198829520, 1198752480,
1198923960, 1198754580, 1199102520, 1198667400, 1198576920, 1199011980,
1199011980, 1198840200, 1198941420, 1198580100, 1199027040, 1199027040,
1198840620, 1198745160, 1198836180, 1198592820, 1198603140, 1198592820,
1198603140, 1199105340, 1199105340, 1198772760, 1198939440, 1198665240,
1198864320, 1198665240, 1198864320, 1198665240, 1198864320, 1198665240,
1198864320, 1198940520, 1198940520, 1198940520, 1199031120, 1198833960,
1198833960, 1198579920, 1198745940, 1198749720, 1198836960, 1198758360,
1198758360, 1198758360, 1198739220, 1198657200, 1198657200, 1198968360,
1198968360, 1198968360, 1198968360, 1198968360, 1198846740, 1198846740,
1198760100, 1198760100), class = c("POSIXct", "POSIXt")), DOLLARS.x = c(9.98,
4.28, 8.58, 1.49, 1.49, 2.19, 2.19, 2.39, 2.21, 0.88, 3, 2.79,
5.58, 2.79, 2.21, 2.21, 4.99, 4.99, 4.99, 4.99, 9.98, 9.98, 0.88,
0.88, 0.88, 4.28, 4.29, 5.58, 2.29, 9, 21.3, 21.3, 13.48, 13.48,
5.99, 5.99, 1.99, 0.88, 0.88, 4.99, 2.3, 2.68, 0.76, 1.98, 4.78,
4.78, 20.22, 20.22, 2.5, 2.5, 0.88, 0.88, 2, 4.29, 9.94, 2.22,
9.99, 9.99, 14.98, 6.36, 6.36, 6.36, 6.36, 6.36, 6.36, 3.33,
3.33, 3.33, 3.33, 3.33, 3.33, 3.33, 3.33, 3.33, 3.33, 3.33, 3.33,
3.33, 3.33, 3.33, 3.33, 3.33, 3.33, 2.98, 2.98, 2.98, 2.98, 2.98,
2.98, 4.97, 4.97, 4.97, 4.97, 4.97, 4.97, 4.97, 4.97, 4.97, 4.97,
4.97, 4.97, 1.64, 1.64, 1.64, 1.64, 1.64, 1.64, 2.99, 2.99, 2.99,
2.99, 2.99, 2.99, 3.99, 3.99, 9.94, 3.99, 9.98, 1.69, 1.69, 4.99,
4.99, 9.99, 9.99, 2.99, 2.99, 0.99, 9.39, 2.99, 10.11, 3.49,
1.99, 2.5, 2.5, 4.28, 3.33, 3.33, 3.33, 0.99, 6.75, 0.88, 28.14,
3.99, 0.99, 10.99, 3.99, 29.99, 4.99, 4.99, 9.94, 9.94, 4.42,
4.28, 7.98, 3.98, 3.49, 9.99, 9.99, 5.78, 18, 8.99, 17.98, 9.99,
4.29, 3.86, 3.5, 12.6, 0.99, 0.88, 1.59, 1.04, 3, 1.99, 4.99,
4.99, 4.28, 4.28, 3.98, 5.49, 12.1, 12.1, 4.29, 4.29, 5.99, 2.99,
8.58, 8.58, 8.58, 8.58, 2.99, 4.99, 9.98, 1.29, 1.29, 1.29, 18.88,
18.88, 18.88, 2.5, 9.98, 4.28, 4.29, 2.39, 2.39, 12, 9.99, 21.98,
21.98, 2.3, 2.09, 2.09, 4.99, 4.99, 1.99, 2.49, 1.19, 1.19, 3.18,
3.18, 3.18, 3.18, 9.44, 9.44, 4.02, 4.02, 3.34, 4.99, 4.99, 2.36,
0.88, 0.5, 3.49, 8.99, 8.99, 8.99, 12, 2.99, 3.98, 14.97, 3.33,
3.33, 1.5, 1.5, 1.5, 3, 1.5, 5.5907348633, 3.29, 13.98, 3.29),
PANID = c(1101626L, 1101626L, 1104703L, 1104935L, 1104935L,
1104935L, 1104935L, 1105759L, 1106781L, 1106781L, 1110460L,
1114892L, 1114892L, 1114892L, 1116814L, 1116814L, 1120618L,
1120618L, 1120618L, 1120618L, 1120618L, 1120618L, 1120618L,
1120618L, 1122242L, 1122242L, 1122242L, 1122242L, 1123752L,
1130930L, 1132282L, 1132282L, 1132282L, 1132282L, 1134692L,
1134692L, 1134692L, 1134692L, 1134692L, 1134692L, 1134692L,
1137273L, 1137273L, 1137273L, 1140707L, 1140707L, 1141721L,
1141721L, 1146563L, 1146563L, 1146563L, 1146563L, 1146894L,
1149815L, 1150359L, 1152744L, 1154153L, 1154153L, 1157727L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1165944L, 1165944L, 1165944L, 1165944L, 1165944L, 1165944L,
1168278L, 1168278L, 1175109L, 1186346L, 1186544L, 1189423L,
1189423L, 1189423L, 1189423L, 1189423L, 1189423L, 1189423L,
1189423L, 1190660L, 1191957L, 1191957L, 1193169L, 1193169L,
1193169L, 1194654L, 1194654L, 1194837L, 1195057L, 1195057L,
1195057L, 1197236L, 1198119L, 1198325L, 1198366L, 1198739L,
1201616L, 1201616L, 1201616L, 1201616L, 1201988L, 1201988L,
1202507L, 1202507L, 1204461L, 1205252L, 1207191L, 1207191L,
1207191L, 1208058L, 1208058L, 1208520L, 1210161L, 1212340L,
1212340L, 1213439L, 1213819L, 1213819L, 1215178L, 1215178L,
1215251L, 1215251L, 1215251L, 1218149L, 1218602L, 1218602L,
1219154L, 1219154L, 1219154L, 1219154L, 1219295L, 1219295L,
1220178L, 1220178L, 1230318L, 1230318L, 1230813L, 1230813L,
1232256L, 1232256L, 1232256L, 1232256L, 1232611L, 1232611L,
1242875L, 1245944L, 1245944L, 1245944L, 1302935L, 1302935L,
1302935L, 1306506L, 1306654L, 1306654L, 1308130L, 1310698L,
1310698L, 1312843L, 1312843L, 1313114L, 1313114L, 1313114L,
1315101L, 1315101L, 1315101L, 1315101L, 1325753L, 1325753L,
1401836L, 1401836L, 1407148L, 1407148L, 1407148L, 1407148L,
1407148L, 1407148L, 1407148L, 1407148L, 1407783L, 1407783L,
1407783L, 1408252L, 1803494L, 1803494L, 1805721L, 1805721L,
1805721L, 1805721L, 1808550L, 1808550L, 1808550L, 1809269L,
1815027L, 1815027L, 3100347L, 3100347L, 3100347L, 3100347L,
3100347L, 3100545L, 3100545L, 3101105L, 3101105L)), row.names = c(NA,
250L), class = "data.frame")