Cerate a pat object for a specific sensor_index.

pat_createNew(
  api_key = NULL,
  pas = NULL,
  sensor_index = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = "UTC",
  average = 0,
  baseUrl = "https://api.purpleair.com/v1/sensors",
  verbose = FALSE
)

Arguments

api_key

PurpleAir API Read Key. If api_key = NULL, it will be obtained using getAPIKey("PurpleAir-read"). See MazamaCoreUtils::setAPIKey.

pas

Previously generated pas object containing sensor_index.

sensor_index

PurpleAir sensor unique identifier.

startdate

Desired start time (ISO 8601) or POSIXct.

enddate

Desired end time (ISO 8601) or POSIXct.

timezone

Olson timezone used to interpret dates.

average

Temporal averaging in minutes performed by PurpleAir. One of: 0 (raw), 10, 30, 60 (hour), 360, 1440 (day).

baseUrl

Base URL for the PurpleAir API.

verbose

Logical controlling the generation of warning and error messages.

Value

A PurpleAir Timeseries pat object.

Examples

# \donttest{
# Fail gracefully if any resources are not available
try({

library(AirSensor)

pat <-
  pat_createNew(
    api_key = PURPLE_AIR_API_READ_KEY,
    pas = example_pas,
    sensor_index = "3515",
    startdate = "2022-07-01",
    enddate = "2022-07-08",
    timezone = "UTC",
    verbose = TRUE
  )

View(pat$meta[1:100,])

}, silent = FALSE)
#> Error in pat_createNew(api_key = PURPLE_AIR_API_READ_KEY, pas = example_pas,  : 
#>   object 'PURPLE_AIR_API_READ_KEY' not found
# }