minObs: Sets minimum values for an obs data frame

View source: R/minObs.R

minObsR Documentation

Sets minimum values for an obs data frame

Description

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

Usage

minObs(
  obs,
  varcols = "",
  minvals = "",
  actions = "min",
  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.

minvals

Optional. A vector containing the minimum 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 minimum threshold values. Currently supported actions are min (using the threshold) and NA (using NA_real_ values). The default is min. 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 smaller than the specified min values are replaced by either NA_real_ or the threshold min values. If unsuccessful, returns an error.

Note

The default threshold values are

t -40 C
ea 0.01 kPa
rh 0.5 percent
ppt 0 mm
p 0 mm
u 0 m/s
SunAct 0 hr
qsi 0 W/m^2
qso 0 W/m^2
qn -60 W/m^2

Author(s)

Kevin Shook

See Also

maxObs

Examples

# use all of the default values
bad.min <- minObs(BadLake7376)
# use specified columns with default min values, replace with 'NA' values
bad.min2 <- minObs(BadLake7376, varcols = c(1, 2), actions = "NA")
# use specfied columns with specified min values and actions
bad.min3 <- minObs(BadLake7376, minvals = c(-30, 22), varcols = c(1, 2), actions = c("min", "NA"))

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