pluck: Quickly filter data

pluck_parameterR Documentation

Quickly filter data

Description

All pluck funtions are wrappers around dplyr::filter(). The dots arguments are converted in a vector and then each function searchs the specific column with the %in% operator.

Usage

pluck_parameter(data, ...)

pluck_interval(data, ...)

pluck_site(data, ...)

pluck_unit(data, ...)

pluck_year(data, ...)

Arguments

data

input data in rolf format

...

elements to get as strings or integers

Value

filtered input data

Windows, symbols and encodings

The first implementation supported symbols as dots arguments. On windows the symbol gets converted to the native encoding without the encoding mark. Is the converted symbol now compared to UTF-8 strings it doesn't match. One example would be strings like "°C" or "µg/m3". See rlang::as_string()

Examples

fn <- system.file("extdata", "smn_multi.txt", package = "rOstluft.data")
data <- read_smn_multiple(fn) %>% dplyr::arrange(starttime)

pluck_parameter(data, "ta1towb0")

# strings or symbols
pluck_site(data, "KLO", "UEB")

# supports splicing with !!!
intervals = c("h1", "d1")
pluck_interval(data, !!!intervals) %>% dplyr::slice(40:45)

# pluck_year supports vector
pluck_year(data, 2010:2012)

# NAs in data aren't a problem
pluck_unit(data, "hPa")

# pipe friendly
data %>%
  pluck_site("KLO", "UEB") %>%
  pluck_parameter("gre000z0") %>%
  pluck_year(2010:2018)

Ostluft/rOstluft documentation built on Feb. 6, 2024, 1:26 a.m.