range_check: Range check function

Description Usage Arguments Value Examples

View source: R/range_check.R

Description

Checking the plausible range of a sequence of observations; The observations should be no less than the lower.bound and no more than the upper.bound; Generating a new sequence of flags, and outputting a new sequence of observations after removing failed observations.

Usage

1
2
3
4
5
6
7
8
range_check(
  data,
  data.column,
  datetime.column,
  upper.bound,
  lower.bound = 0,
  monthly.bounds = TRUE
)

Arguments

data

a data.frame that includes observation data with information.

data.column

a character, the selected column name in the data.frame that represents observation data to be checked.

datetime.column

a character, the selected column name in the data.frame that represents the reporting dates and times of corresponding observations.

upper.bound

a real number that controls the maximum allowed value of observations.

lower.bound

a real number that controls the minimum required value of observations (default value = 0).

monthly.bounds

a logical, if TRUE, then the range check is performed with different monthly upper bounds, in this case the upper.bound and lower.bound must be a numeric vector of length 12, if lower.bound use default value, then there is no need to take actions.

Value

a new tbl_df that extends two new columns on the input data, the first added column flag_range represents the flags (P means pass, fail.range means fail, missing means missing values of observations), the second added column new_data_range represents the observation data after removing failed observations.

Examples

1
2
3
4
5
6
7
8
library(tidyverse)
datetime = as.POSIXct(seq(0,60000,600), origin = "2017-02-03 08:00:00")
test_data = tibble(datetime = datetime,
              windspeed = c(0:20,20:1,1:20,20:1,1:20))
test_range_check = range_check(test_data, data.column = 'windspeed',
                               datetime.column = 'datetime', upper.bound = c(11:22))
attributes(test_range_check)
test_range_check

jieyu97/QCwind documentation built on June 18, 2021, 3:37 a.m.