df.melt[1:10,]
t variable value
1 2020-10-01 10 13
2 2020-10-02 10 18
3 2020-10-03 10 11
4 2020-10-04 10 7
5 2020-10-05 10 5
6 2020-10-06 10 16
7 2020-10-07 10 3
8 2020-10-08 10 12
9 2020-10-09 10 20
10 2020-10-10 10 29
df.melt[289:299,]
t variable value
289 2020-10-01 20 60
290 2020-10-02 20 48
291 2020-10-03 20 60
292 2020-10-04 20 31
293 2020-10-05 20 17
294 2020-10-06 20 44
295 2020-10-07 20 28
296 2020-10-08 20 49
297 2020-10-09 20 60
298 2020-10-10 20 64
299 2020-10-11 20 38
dplyr::filter(df.melt,variable>=10 & variable < 21) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value))
# A tibble: 288 x 2
t `sum(value)`
<date> <dbl>
1 2020-10-01 73
2 2020-10-02 66
3 2020-10-03 71
4 2020-10-04 38
5 2020-10-05 22
6 2020-10-06 60
7 2020-10-07 31
8 2020-10-08 61
9 2020-10-09 80
10 2020-10-10 93
# ... with 278 more rows
dplyr::filter(df.melt,variable>=10 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value))
# A tibble: 289 x 2
t `sum(value)`
<date> <dbl>
1 2020-10-01 234
2 2020-10-02 196
3 2020-10-03 205
4 2020-10-04 107
5 2020-10-05 65
6 2020-10-06 176
7 2020-10-07 140
8 2020-10-08 248
9 2020-10-09 203
10 2020-10-10 248
# ... with 279 more rows
dplyr::filter(df.melt,variable>=70 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value))
# A tibble: 289 x 2
t `sum(value)`
<date> <dbl>
1 2020-10-01 31
2 2020-10-02 20
3 2020-10-03 21
4 2020-10-04 13
5 2020-10-05 6
6 2020-10-06 20
7 2020-10-07 22
8 2020-10-08 25
9 2020-10-09 17
10 2020-10-10 33
# ... with 279 more rows
(dplyr::filter(df.melt,variable>=70 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value)))[,2] / as.vector(dplyr::filter(df.melt,variable>=10 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value)))[,2]
sum(value)
1 0.13247863
2 0.10204082
3 0.10243902
4 0.12149533
5 0.09230769
6 0.11363636
7 0.15714286
8 0.10080645
9 0.08374384
10 0.13306452
<Skip>
282 0.02311436
283 0.04105263
284 0.03094463
285 0.02589641
286 0.03855422
287 0.02872063
288 0.02675841
289 0.02281668
plot(as.xts( (dplyr::filter(df.melt,variable>=70 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value)))[,2] / as.vector(dplyr::filter(df.melt,variable>=10 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value)))[,2],df.melt$t[1:289]))
OR
plot(as.xts( (dplyr::filter(df.melt,variable>=70 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value)))[,2] / as.vector(dplyr::filter(df.melt,variable>=10 ) %>% dplyr::group_by(t) %>% dplyr::summarise(.,sum(value)))[,2],unique(df.melt$t)))
0 件のコメント:
コメントを投稿