-1

I have a timeseries of daily dataset for 10 years. I want to convert it to monthly dataset for 10 years, however the monthly values will be quantiles rather than the average of that month. How to perform this using R?

neilfws
  • 32,751
  • 5
  • 50
  • 63

1 Answers1

1

You may do this task with the tsibble package. I am using weather data from nycflights13 R package, that is a hourly dataset.

library(nycflights13)
library(tsibble)

nycflights13::weather %>% 
  mutate(time_month = yearmonth(time_hour)) %>% 
  group_by(origin, time_month) %>% 
  summarise(temp_q25 = quantile(temp, probs = .25, na.rm=T))

   origin time_month temp_q25
   <chr>       <mth>    <dbl>
 1 EWR      2013 Jan     28.9
 2 EWR      2013 Feb     28.9
 3 EWR      2013 Mär     35.1
 4 EWR      2013 Apr     46.9
 5 EWR      2013 Mai     55.9
 6 EWR      2013 Jun     66.9
 7 EWR      2013 Jul     75.9
 8 EWR      2013 Aug     71.1
 9 EWR      2013 Sep     60.1
10 EWR      2013 Okt     53.1
Simon Müller
  • 368
  • 2
  • 5