filter_obs: Filter observation list to exclude situations, variables or...

View source: R/filter_obs.R

filter_obsR Documentation

Filter observation list to exclude situations, variables or dates

Description

Filter observation list to exclude situations, variables or dates

Usage

filter_obs(
  obs_list,
  var = NULL,
  situation = NULL,
  dates = NULL,
  include = FALSE,
  var_names = lifecycle::deprecated(),
  sit_names = lifecycle::deprecated()
)

Arguments

obs_list

List of observed values to use for parameter estimation. A ⁠named list⁠ (names = situations names) of data.frame containing one column named Date with the dates (Date or POSIXct format) of the different observations and one column per observed variables with either the measured values or NA, if the variable is not observed at the given date. See details section for more information on the list of observations actually used during the parameter estimation process.

var

(optional, if not given all variables will be kept) Vector containing the names of the variables to include or exclude

situation

(optional, if not given all situations will be kept) Vector containing the names of the situations to include or exclude

dates

(optional, if not given all dates will be kept) Vector containing the dates (POSIXct format) to include or exclude

include

(optional, FALSE by default) Flag indicating if the variables / situations / dates listed in inputs must be included (TRUE) or not (FALSE) in the resulting list

var_names

[Deprecated] var_names is no longer supported, use var instead.

sit_names

[Deprecated] sit_names is no longer supported, use situation instead.

Value

obs_list List of filtered observed values (same format as obs_list input argument)

See Also

For more detail and examples, see the different vignettes in CroptimizR website

Examples


obs_list <- list(
  sit1 = data.frame(
    Date = as.POSIXct(c("2009-11-30", "2009-12-10")),
    var1 = c(1.1, 1.5), var2 = c(NA, 2.1)
  ),
  sit2 = data.frame(
    Date = as.POSIXct(c("2009-11-30", "2009-12-5")),
    var1 = c(1.3, 2)
  )
)

# Keep only var1
filter_obs(obs_list, var = c("var1"), include = TRUE)

# Exclude observations at date "2009-11-30"
filter_obs(obs_list, dates = as.POSIXct(c("2009-11-30")))


SticsRPacks/CroptimizR documentation built on Dec. 16, 2024, 11:54 a.m.