Converts the contents of the monitor
argument to CSV.
By default, the output is a text string with "human readable" CSV that
includes both meta
and data
. When saved as a file, this format
is useful for point-and-click spreadsheet users who want to have everything
on a single sheet.
To obtain a machine parseable CSV string for just the data, you can use
includeMeta = FALSE
. To obtain machine parseable metadata, use
includeData = FALSE
.
monitor_toCSV(monitor, includeMeta = TRUE, includeData = TRUE)
mts_monitor object.
Logical specifying whether to include monitor$meta
.
Logical specifying whether to include monitor$data
.
CSV formatted text.
library(AirMonitor)
monitor <-
Carmel_Valley %>%
monitor_filterDate(20160802, 20160803)
monitor_toCSV(monitor) %>% cat()
#> ##### Site metadata begins below here,NA,NA
#> parameter,blank,a9572a904a4ed46d_840060530002
#> deviceDeploymentID,,a9572a904a4ed46d_840060530002
#> deviceID,,840060530002
#> deviceType,,NA
#> deviceDescription,,NA
#> deviceExtra,,NA
#> pollutant,,PM2.5
#> units,,UG/M3
#> dataIngestSource,,AirNow
#> dataIngestURL,,https://www.airnowapi.org/aq/data/
#> dataIngestUnitID,,NA
#> dataIngestExtra,,NA
#> dataIngestDescription,,NA
#> locationID,,a9572a904a4ed46d
#> locationName,,Carmel Valley AMS
#> longitude,,-121.7333
#> latitude,,36.48187
#> elevation,,200.1
#> countryCode,,US
#> stateCode,,CA
#> countyName,,Monterey
#> timezone,,America/Los_Angeles
#> houseNumber,,NA
#> street,,Ford Road
#> city,,NA
#> zip,,NA
#> AQSID,,060530002
#> fullAQSID,,840060530002
#> ##### Hourly data begins below here,NA,NA
#> UTC Time,Local Time,a9572a904a4ed46d_840060530002
#> 2016-08-02 07:00:00 UTC,2016-08-02 00:00:00 PDT,26
#> 2016-08-02 08:00:00 UTC,2016-08-02 01:00:00 PDT,31
#> 2016-08-02 09:00:00 UTC,2016-08-02 02:00:00 PDT,38
#> 2016-08-02 10:00:00 UTC,2016-08-02 03:00:00 PDT,47
#> 2016-08-02 11:00:00 UTC,2016-08-02 04:00:00 PDT,76
#> 2016-08-02 12:00:00 UTC,2016-08-02 05:00:00 PDT,99
#> 2016-08-02 13:00:00 UTC,2016-08-02 06:00:00 PDT,126
#> 2016-08-02 14:00:00 UTC,2016-08-02 07:00:00 PDT,142
#> 2016-08-02 15:00:00 UTC,2016-08-02 08:00:00 PDT,156
#> 2016-08-02 16:00:00 UTC,2016-08-02 09:00:00 PDT,129
#> 2016-08-02 17:00:00 UTC,2016-08-02 10:00:00 PDT,NA
#> 2016-08-02 18:00:00 UTC,2016-08-02 11:00:00 PDT,100
#> 2016-08-02 19:00:00 UTC,2016-08-02 12:00:00 PDT,90
#> 2016-08-02 20:00:00 UTC,2016-08-02 13:00:00 PDT,33
#> 2016-08-02 21:00:00 UTC,2016-08-02 14:00:00 PDT,16
#> 2016-08-02 22:00:00 UTC,2016-08-02 15:00:00 PDT,8
#> 2016-08-02 23:00:00 UTC,2016-08-02 16:00:00 PDT,9
#> 2016-08-03 00:00:00 UTC,2016-08-02 17:00:00 PDT,9
#> 2016-08-03 01:00:00 UTC,2016-08-02 18:00:00 PDT,9
#> 2016-08-03 02:00:00 UTC,2016-08-02 19:00:00 PDT,9
#> 2016-08-03 03:00:00 UTC,2016-08-02 20:00:00 PDT,6
#> 2016-08-03 04:00:00 UTC,2016-08-02 21:00:00 PDT,5
#> 2016-08-03 05:00:00 UTC,2016-08-02 22:00:00 PDT,6
#> 2016-08-03 06:00:00 UTC,2016-08-02 23:00:00 PDT,9
monitor_toCSV(monitor, includeData = FALSE) %>% cat()
#> deviceDeploymentID,deviceID,deviceType,deviceDescription,deviceExtra,pollutant,units,dataIngestSource,dataIngestURL,dataIngestUnitID,dataIngestExtra,dataIngestDescription,locationID,locationName,longitude,latitude,elevation,countryCode,stateCode,countyName,timezone,houseNumber,street,city,zip,AQSID,fullAQSID,airnow_stationID,airnow_parameterName,airnow_monitorType,airnow_siteCode,airnow_status,airnow_agencyID,airnow_agencyName,airnow_EPARegion,airnow_GMTOffsetHours,airnow_CBSA_ID,airnow_CBSA_Name,airnow_stateAQSCode,airnow_countyAQSCode,airnow_MSAName,address,deploymentType
#> a9572a904a4ed46d_840060530002,840060530002,NA,NA,NA,PM2.5,UG/M3,AirNow,https://www.airnowapi.org/aq/data/,NA,NA,NA,a9572a904a4ed46d,Carmel Valley AMS,-121.73333,36.48187,200.1,US,CA,Monterey,America/Los_Angeles,NA,Ford Road,NA,NA,060530002,840060530002,060530002,PM2.5,Permanent,0002,Active,MON,Monterey Bay Unified APCD,R9,-8,41500," Salinas, CA ",06,053,NA,"Tularcitos Elementary School, Ford Road, Carmel Valley, Monterey County, CA, United States of America",Permanent
monitor_toCSV(monitor, includeMeta = FALSE) %>% cat()
#> UTC Time,Local Time,a9572a904a4ed46d_840060530002
#> 2016-08-02 07:00:00 UTC,2016-08-02 00:00:00 PDT,26
#> 2016-08-02 08:00:00 UTC,2016-08-02 01:00:00 PDT,31
#> 2016-08-02 09:00:00 UTC,2016-08-02 02:00:00 PDT,38
#> 2016-08-02 10:00:00 UTC,2016-08-02 03:00:00 PDT,47
#> 2016-08-02 11:00:00 UTC,2016-08-02 04:00:00 PDT,76
#> 2016-08-02 12:00:00 UTC,2016-08-02 05:00:00 PDT,99
#> 2016-08-02 13:00:00 UTC,2016-08-02 06:00:00 PDT,126
#> 2016-08-02 14:00:00 UTC,2016-08-02 07:00:00 PDT,142
#> 2016-08-02 15:00:00 UTC,2016-08-02 08:00:00 PDT,156
#> 2016-08-02 16:00:00 UTC,2016-08-02 09:00:00 PDT,129
#> 2016-08-02 17:00:00 UTC,2016-08-02 10:00:00 PDT,NA
#> 2016-08-02 18:00:00 UTC,2016-08-02 11:00:00 PDT,100
#> 2016-08-02 19:00:00 UTC,2016-08-02 12:00:00 PDT,90
#> 2016-08-02 20:00:00 UTC,2016-08-02 13:00:00 PDT,33
#> 2016-08-02 21:00:00 UTC,2016-08-02 14:00:00 PDT,16
#> 2016-08-02 22:00:00 UTC,2016-08-02 15:00:00 PDT,8
#> 2016-08-02 23:00:00 UTC,2016-08-02 16:00:00 PDT,9
#> 2016-08-03 00:00:00 UTC,2016-08-02 17:00:00 PDT,9
#> 2016-08-03 01:00:00 UTC,2016-08-02 18:00:00 PDT,9
#> 2016-08-03 02:00:00 UTC,2016-08-02 19:00:00 PDT,9
#> 2016-08-03 03:00:00 UTC,2016-08-02 20:00:00 PDT,6
#> 2016-08-03 04:00:00 UTC,2016-08-02 21:00:00 PDT,5
#> 2016-08-03 05:00:00 UTC,2016-08-02 22:00:00 PDT,6
#> 2016-08-03 06:00:00 UTC,2016-08-02 23:00:00 PDT,9