pad_to_year_fill: Pads data to complete year and fill up specific columns

View source: R/pad.R

pad_to_year_fillR Documentation

Pads data to complete year and fill up specific columns

Description

This function pad data to complete years. The fill mechanism is:

  • find min- and max time

  • group data by columns provided by ... or all factor/character columns

  • dplyr::group_nest()

  • pass the nested data for each group to pad_to_year() with the min- and max time

  • tidyr::unnest()

Usage

pad_to_year_fill(data, date_col, interval, ...)

Arguments

data

input data

date_col

column containing time information

interval

interval between two dates. See seq.POSIXt() for valid values

...

columns to fill up

Value

padded data

Examples

fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_min30_2013_Jan.csv")
data <- rOstluft::read_airmo_csv(fn)

tail(data)

# fills up all factor and character columns
pad_to_year_fill(data, starttime, "30 min") %>% tail()

# or only the specific and the rest with na
pad_to_year_fill(data, starttime, "30 min", site) %>% tail()

# data in wide format
data <- rOstluft::rolf_to_openair(data)
pad_to_year_fill(data, date, "30 min") %>% tail()

# but be careful not to include cutting factors
data <- openair::cutData(data, "month") %>%
  dplyr::select(month, dplyr::everything())

# fills up month and would multiply the data by the numbers of months
pad_to_year_fill(data, date, "30 min") %>% tail()

# only fills up the site column
pad_to_year_fill(data, date, "30 min", site) %>% tail()

Ostluft/rOstluft.plot documentation built on Jan. 26, 2025, 1:05 a.m.