openair icon indicating copy to clipboard operation
openair copied to clipboard

aqStats not working with CO

Open simonadzs opened this issue 5 years ago • 1 comments

Hallo. I found a problem using aqStats-Openair2.6-1, when "pollutant" includes carbon oxide (CO) among others. Example: if x is a dataframe with hourly data 1)stat<- aqStats(x, pollutant=c("so2","no2","o3","nox","nor","co"),data.thresh=75,transpose = TRUE) does not work 2)stat<- aqStats(x, pollutant=c("so2","no2","o3","nox","nor","co"),data.thresh=75,transpose=FALSE) works, but stat$pollutant is not correct I think this is caused by function calcStats: one of the last lines of this function should be deleted. The line is "co.results$pollutant <- "CO", corresponding to line 366 in the code given in https://github.com/cran/openair/blob/master/R/aqStats.R Is it something already fixed in some way? Thanks

simonadzs avatar Mar 20 '19 14:03 simonadzs

thanks. I need to update this function but have hopefully fixed the problem you reported.

davidcarslaw avatar Mar 21 '19 08:03 davidcarslaw

Closing as this appears to be fixed.

openair::aqStats(
  openair::selectByDate(openair::mydata, year = 2000),
  pollutant = c("so2", "nox", "o3", "co"),
  data.thresh = 75,
  transpose = FALSE
)
#> # A tibble: 4 × 17
#> # Groups:   default, pollutant, year [4]
#>   default   pollu…¹  year date                dat.cap   mean   min    max median
#>   <fct>     <chr>   <dbl> <dttm>                <dbl>  <dbl> <dbl>  <dbl>  <dbl>
#> 1 01 Janua… co       2000 2000-01-01 00:00:00    95.9   2.01     0   8.51   1.75
#> 2 01 Janua… nox      2000 2000-01-01 00:00:00    96.3 217.       4 966    193   
#> 3 01 Janua… o3       2000 2000-01-01 00:00:00    98.8   6.62     0  48      4   
#> 4 01 Janua… so2      2000 2000-01-01 00:00:00    95.8   5.44     0  43.3    4.92
#> # … with 8 more variables: max_daily <dbl>, roll_8_max <dbl>,
#> #   roll_24_max <dbl>, percentile.95 <dbl>, percentile.99 <dbl>,
#> #   roll.8.O3.gt.100 <int>, roll.8.O3.gt.120 <int>, AOT40 <dbl>, and
#> #   abbreviated variable name ¹​pollutant

Created on 2023-02-10 with reprex v2.0.2

jack-davison avatar Feb 10 '23 08:02 jack-davison