maxObs: Sets maximum values for an obs data frame

View source: R/maxObs.R

maxObsR Documentation

Sets maximum values for an obs data frame

Description

Tests values in a CRHMr obs data frame to see if they exceed maximum thresholds. Values exceeding the thresholds can be set to either the maximum allowable value or to NA_real_, which is useful for infilling or imputing values.

Usage

maxObs(
  obs,
  varcols = "",
  maxvals = "",
  actions = "max",
  quiet = TRUE,
  logfile = ""
)

Arguments

obs

Required. The CRHMr obs data frame.

varcols

Optional. A vector containing the columns to be imputed in the obs data frame, not including the datetime. If not specified, defaults to all columns.

maxvals

Optional. A vector containing the maximum permissible values for each of the specified columns. If omitted, the default values are used.

actions

Optional. A vector containing the methods to be used for replacing values that exceed the maximum threshold values. Currently supported actions are max (using the threshold) and NA (inserting NA_real_ values). The default is max. If fewer actions are specified than variables, then the actions are recycled.

quiet

Optional. Suppresses display of messages, except for errors. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default). If you are working interactively, you will probably want to set quiet=FALSE.

logfile

Optional. Name of the file to be used for logging the action. Normally not used.

Value

If successful, returns a modified version of the obs data frame. The values exceeding the specified max values are replaced by either NA_real_ or the threshold max values. If unsuccessful, returns the value FALSE.

Note

The default threshold values are

t 40 C
ea 3.5 kPa
rh 100 percent
ppt 100 mm
p 20 mm
u 10 m/s
SunAct 18 hr
qsi 1262 W/m^2
qso 1000 W/m^2
qn 250 W/m^2

Author(s)

Kevin Shook

See Also

minObs

Examples

# use all of the default values
bad.max <- maxObs(BadLake7376)
summary(bad.max)
# use specified columns with default max values, replace with 'NA' values
bad.max2 <- maxObs(BadLake7376, varcols = c(1, 2), actions = "NA")
# use specfied columns with specified max values and actions
bad.max3 <- maxObs(BadLake7376, maxvals = c(35, 10), varcols = c(1, 3), actions = c("NA", "max"))
summary(bad.max3)

CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.