pat_dygraph: Interactive time series plot

Description Usage Arguments Value Examples

View source: R/pat_dygraph.R

Description

This function creates interactive graphs that will be displayed in RStudio's 'Viewer' tab.

The list of available parameters include:

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pat_dygraph(
  pat = NULL,
  parameter = "pm25",
  sampleSize = 5000,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  tlim = NULL,
  rollPeriod = 1,
  showLegend = TRUE,
  colors = NULL,
  timezone = NULL
)

Arguments

pat

PurpleAir Timeseries pat object from pat_createNew()

parameter

Data to display: "pm25", "humidity", "temperature" or "pressure".

sampleSize

Either an integer or fraction to determine sample size.

title

title text

xlab

optional title for the x axis

ylab

optional title for the y axis

tlim

optional vector with start and end times (integer or character representing YYYYMMDD[HH])

rollPeriod

Width (hours) of rolling mean to be applied to the data.

showLegend

Logical specifying whether to add a legend.

colors

Vector of colors to be used for plotting.

timezone

Olson timezone used to interpret tlim. (Defaults to pat local time.)

Value

Initiates the interactive dygraph plot in RStudio's 'Viewer' tab.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(AirSensor)

# Create a new pat object for North Bend, WA
North_Bend_Weather <- 
  pat_createNew(
    label = "North Bend Weather", 
    pas = example_pas,
    startdate = 20180801, 
    enddate = 20180901,
    verbose = TRUE
  )

if ( interactive() ) {
  # Create interactive timeseries plot
  #  - sample just 1000 points for more efficient plotting
  #  - plot using a 6-hour rolling mean to fill in holes
  North_Bend_Weather %>%
    pat_sample(sampleSize = 1000, setSeed = 1) %>%
    pat_dygraph(xlab = "2018", rollPeriod = 6)
}

AirSensor documentation built on March 13, 2021, 1:07 a.m.