#> # … with 1,510 more rows # Rounding to financial year, using a custom function financial_year % index_by (Year = ~ financial_year (. #> 10 Adelaide South Australia 2007 2317. ) ) %>% group_by ( Region, State ) %>% summarise (Total = sum ( Trips ) ) #> # A tsibble: 1,520 x 4 #> # Key: Region, State #> # Groups: Region #> Region State Year Total #> #> 1 Adelaide South Australia 1998 2226. ) ) %>% summarise ( Max_Count = max ( Count ), Min_Count = min ( Count ) ) monthly_ped #> # A tsibble: 95 x 4 #> # Key: Sensor #> Sensor Year_Month Max_Count Min_Count #> #> 1 Birrarung Marr 20 1 #> 2 Birrarung Marr 201 1 #> 3 Birrarung Marr 20 1 #> 4 Birrarung Marr 20 1 #> 5 Birrarung Marr 20 1 #> 6 Birrarung Marr 20 0 #> 7 Birrarung Marr 204 1 #> 8 Birrarung Marr 20 0 #> 9 Birrarung Marr 20 0 #> 10 Birrarung Marr 20 1 #> # … with 85 more rows index ( monthly_ped ) #> Year_Month # Using existing variable pedestrian %>% group_by_key ( ) %>% index_by ( Date ) %>% summarise ( Max_Count = max ( Count ), Min_Count = min ( Count ) ) #> # A tsibble: 2,752 x 4 #> # Key: Sensor #> Sensor Date Max_Count Min_Count #> #> 1 Birrarung Marr 1630 44 #> 2 Birrarung Marr 352 1 #> 3 Birrarung Marr 226 3 #> 4 Birrarung Marr 852 4 #> 5 Birrarung Marr 1427 3 #> 6 Birrarung Marr 937 5 #> 7 Birrarung Marr 708 4 #> 8 Birrarung Marr 568 9 #> 9 Birrarung Marr 1629 5 #> 10 Birrarung Marr 2439 10 #> # … with 2,742 more rows # Attempt to aggregate to 4-hour interval, with the effects of DST pedestrian %>% group_by_key ( ) %>% index_by (Date_Time4 = ~ lubridate :: floor_date (. Instead, in Stata, the first week begins on January 1, regardless of which day of the week that is, and every 7 days we start a new weeks, except that week 52 gets extended to include the extra day or days remaining in December.Pedestrian %>% index_by ( ) #> # A tsibble: 66,037 x 5 #> # Key: Sensor #> # Groups: Date_Time #> Sensor Date_Time Date Time Count #> #> 1 Birrarung Marr 00:00:00 0 1630 #> 2 Birrarung Marr 01:00:00 1 826 #> 3 Birrarung Marr 02:00:00 2 567 #> 4 Birrarung Marr 03:00:00 3 264 #> 5 Birrarung Marr 04:00:00 4 139 #> 6 Birrarung Marr 05:00:00 5 77 #> 7 Birrarung Marr 06:00:00 6 44 #> 8 Birrarung Marr 07:00:00 7 56 #> 9 Birrarung Marr 08:00:00 8 113 #> 10 Birrarung Marr 09:00:00 9 166 #> # … with 66,027 more rows # Monthly counts across sensors library ( dplyr, nflicts = FALSE ) monthly_ped % group_by_key ( ) %>% index_by (Year_Month = ~ yearmonth (. Stata date weekly date functions do not work that way. I see that in your data, you have an observation with week = 53. Also, there is no consistently used definition of a week. In fact, there is no truly consistent way to do it because some weeks straddle two different months. I also decided to shorten weekly_count to n_, just to save on typing.Īs for aggregating weekly data to monthly, that is quite complicated. It is made somewhat more complicated because your indicator values contain trailing blanks-those have to be removed first. The first part, creating separate variables ("columns") for cases and deaths is a fairly straightforward application of -reshape. My question is now how can firstly separate death and case as a single column for each country?įurthermore how could I simply sum weekly_count data to obtain monthly data?
0 Comments
Leave a Reply. |