Skip to content
Prev 381397 / 398502 Next

Query about calculating the monthly average of daily data columns

Does this do what you want:
+ 111 19940103 0.025464308
+ 111 19940104 0.064424296
+ 111 19940105 0.018579337
+ 111 19940106 0.018872211
 ..." ... [TRUNCATED]
+   group_by(PERMNO, month = DATE %/% 100) %>%
+   summarise(avg = mean(Spread))
# A tibble: 12 x 3
# Groups:   PERMNO [3]
   PERMNO  month      avg
    <dbl>  <dbl>    <dbl>
 1    111 199401 0.0416
 2    111 199402 0.0508
 3    111 199403 0.0567
 4    111 199404 0.0466
 5    112 199401 0.000533
 6    112 199402 0.000593
 7    112 199403 0.000471
 8    112 199404 0.000587
 9    113 199401 0.000692
10    113 199402 0.000591
11    113 199403 0.000677
12    113 199404 0.000555
Jim Holtman
*Data Munger Guru*


*What is the problem that you are trying to solve?Tell me what you want to
do, not how you want to do it.*


On Sun, Oct 20, 2019 at 5:10 AM Subhamitra Patra <subhamitra.patra at gmail.com>
wrote: