add_by_id_and_range: Function to add a variable by testing an identifier and a...

View source: R/add_by_id_and_range.R

add_by_id_and_rangeR Documentation

Function to add a variable by testing an identifier and a range.

Description

Function to add a variable by testing an identifier and a range.

Usage

add_by_id_and_range(df, test, df_map, by, min, max, add)

Arguments

df

Data frame to test.

test

Variable in df for the range test.

df_map

Mapping data frame containing by, min, max, and add variables.

by

An identifying variable (or up to three) in both df and df_map which is to be used for the matching test.

min, max

Variables in df_map which will be used for the range test, i.e., is test between min and max?

add

Variable in df_map to add to df. Generally, this will be an integer key.

Value

Tibble.

Author(s)

Stuart K. Grange

Examples


## Not run: 

# Add a site variable based on sensor_id and date ranges to an observation
# table containing time series
add_by_id_and_range(
  data_observations,
  test = "date",
  df_map = data_site_ranges,
  by = "sensor_id",
  min = "date_start",
  max = "date_end",
  add = "site"
)


## End(Not run)


skgrange/threadr documentation built on April 15, 2024, 9:35 p.m.