I have 5 year data from 2017 to 2021 with pollutants pm2.5 , no2 , so2, and co. how can I find the yearly mean, standard deviation and median of each pollutants for each year?
library(openair)
pm2.5avg <- mean(newdata$pm25, year="2017", na.rm=TRUE)
I have 5 year data from 2017 to 2021 with pollutants pm2.5 , no2 , so2, and co. how can I find the yearly mean, standard deviation and median of each pollutants for each year?
library(openair)
pm2.5avg <- mean(newdata$pm25, year="2017", na.rm=TRUE)
library(tidyverse)
library(lubridate)
newdata <- openair::mydata
newdata %>%
filter(between(year(date), 2001, 2005)) %>%
group_by(year = year(date)) %>%
summarise(across(pm25, list(
mean = mean, sd = sd, median = median
), na.rm = TRUE))
#> # A tibble: 5 × 4
#> year pm25_mean pm25_sd pm25_median
#> <dbl> <dbl> <dbl> <dbl>
#> 1 2001 25.0 17.0 22
#> 2 2002 21.4 9.94 20
#> 3 2003 19.1 10.4 17
#> 4 2004 19.3 9.36 18
#> 5 2005 18.0 9.79 16
Created on 2023-01-25 with reprex v2.0.2