0

I have the following data for 7 years (2012-2018) and need to calculate the median for every month for all the years. Thank you for any help!

    Ano   Mes   Dia  Hora     UI   Date               
   <dbl> <dbl> <dbl> <dbl>   <dbl> <dttm>             
 1  2012     1     1     0   37.9  2012-01-01 00:00:00
 2  2012     1     1     6    9.18 2012-01-01 06:00:00
 3  2012     1     1    12    1.18 2012-01-01 12:00:00
 4  2012     1     1    18   27.0  2012-01-01 18:00:00
 5  2012     1     2     0 -292.   2012-01-02 00:00:00
 6  2012     1     2     6   98.2  2012-01-02 06:00:00
 7  2012     1     2    12   95.9  2012-01-02 12:00:00
 8  2012     1     2    18    6.19 2012-01-02 18:00:00
 9  2012     1     3     0   -4.65 2012-01-03 00:00:00
10  2012     1     3     6   40.1  2012-01-03 06:00:00
# ... with 10,215 more rows
macs2021
  • 85
  • 1
  • 7

1 Answers1

0
df %>%
 group_by(Mes) %>%
 summarise(median_ui = median(UI))
John J.
  • 1,450
  • 1
  • 13
  • 28
  • 2
    Or `group_by(And, Mes)` for groups by year AND month. – Dave2e Jan 30 '21 at 19:44
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – blackbishop Jan 30 '21 at 19:47
  • Thank you for the answers! I'm new on the platform and will learn to improve my questions! – macs2021 Jan 30 '21 at 22:05