plot_station_measurements: Descriptive plot of daily time series data

View source: R/visualisation.R

plot_station_measurementsR Documentation

Descriptive plot of daily time series data

Description

This function produces descriptive time-series plots with smoothing for the meteorological and potential target variables that were measured at a station.

Usage

plot_station_measurements(
  env_data,
  variables,
  years = NULL,
  smoothing_factor = 1
)

Arguments

env_data

A data table of measurements of one air quality measurement station. The data should contain the following columns:

Station

Station identifier where the data was collected.

Komponente

The environmental component being measured (e.g., temperature, NO2).

Wert

The measured value of the component.

date

The timestamp for the observation, formatted as a Date-Time object in the format "YYYY-MM-DD HH:MM:SS" (e.g., "2010-01-01 07:00:00").

Komponente_txt

A textual description or label for the component.

variables

list of variables to plot. Must be in env_data$Komponente. Meteorological variables can be obtained from params.yaml.

years

Optional. A numeric vector, list, or a range specifying the years to restrict the plotted data. You can provide:

  • A single year: years = 2020

  • A numeric vector of years: years = c(2019, 2020, 2021)

  • A range of years: years = 2019:2021 If not provided, data for all available years will be used.

smoothing_factor

A number that defines the magnitude of smoothing. Default is 1. Smaller numbers correspond to less smoothing, larger numbers to more.

Value

A ggplot object. This object contains:

  • A time-series line plot for each variable in variables.

  • Smoothed lines, with smoothing defined by smoothing_factor.

Examples

library(data.table)
env_data <- data.table(
  Station = "Station_1",
  Komponente = rep(c("TMP", "NO2"), length.out = 100),
  Wert = rnorm(100, mean = 20, sd = 5),
  date = rep(seq.POSIXt(as.POSIXct("2022-01-01"), , "hour", 50), each = 2),
  year = 2022,
  Komponente_txt = rep(c("Temperature", "NO2"), length.out = 100)
)
plot <- plot_station_measurements(env_data, variables = c("TMP", "NO2"))


ubair documentation built on April 12, 2025, 2:12 a.m.