Learn R Programming

AirSensor (version 1.0.8)

pat_downloadParseRawData: Download PurpleAir timeseries data

Description

Downloads timeseries data for a specific PurpleAir sensor from the ThingSpeak API and parses the content into individual dataframes. This function will always return dataframes with the appropriate columns even if no data are returned from ThingSpeak.

The returned list contains the following dataframes:

  • meta -- pas records for the specified sensor

  • A_PRIMARY -- channel A primary dataset

  • A_SECONDARY -- channel A secondary dataset

  • B_PRIMARY -- channel B primary dataset

  • B_SECONDARY -- channel B secondary dataset

These dataframes contain ALL data available from ThingSpeak for the specified sensor and time period.

See the references.

Usage

pat_downloadParseRawData(
  id = NULL,
  label = NULL,
  pas = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = NULL,
  baseUrl = "https://api.thingspeak.com/channels/"
)

Arguments

id

PurpleAir sensor 'deviceDeploymentID'.

label

PurpleAir sensor 'label'.

pas

PurpleAir Synoptic pas object.

startdate

Desired start time (ISO 8601).

enddate

Desired end time (ISO 8601).

timezone

Timezone used to interpret start and end dates.

baseUrl

Base URL for Thingspeak API.

Value

List containing multiple timeseries dataframes.

References

https://www2.purpleair.com/community/faq#!hc-sd-card-csv-file-header

Examples

Run this code
# NOT RUN {
library(AirSensor)

setArchiveBaseUrl("http://data.mazamascience.com/PurpleAir/v1")

pas <- pas_load()

pat_rawList <- 
  pat_downloadParseRawData(
    id = "78df3c292c8448f7_21257",
    pas = pas
  )

lapply(pat_rawList, head)
# }

Run the code above in your browser using DataLab