Extract plot datapoints from a diurnal plot generated using R openair timevariation function

53 views Asked by At

*I have used the following code and extracted the data for the "hour" subplot from the tibble. However, I have forgotten how to do it now. I am not sure if I am missing any code at the bottom. Please modify the below and let me know how to get the data in CSV or text format. *

**

library(readxl)
library(tidyverse)
library(openair)
library(dplyr)

Georgia <- read_excel("C:/Users/TT/Desktop/FT/AA/Daily Average/Georgia.xlsx", 
                   sheet = "Refined Data", col_types = c("text", 
                                                         "text", "date", "numeric", "numeric", 
                                                         "numeric", "numeric", "numeric", 
                                                         "numeric", "text", "numeric", "text", 
                                                         "text", "text"))

tail(timeVariation(selectByDate(Georgia, year = 2017), pollutant = "pm2.5", group = "month"), subset ="hour")

**

The tibble I need to extract :

1

There are 1 answers

0
Ben On

The openair package comes with test data. Here is an example on how to extract the data for the hour plot.

Here we create a tv object which is the result of timeVariation function using the example data:

library(openair)

tv <- timeVariation(mydata, pollutant = "nox")

To access the plotted data including mean and confidence intervals, you can then use:

tv$data$hour

Or, to store in a .csv file, try (include filename of interest):

write.csv(tv$data$hour, "openair_mydata.csv")