R/filter_obs.R
filter_obs.Rd
Filter observation list to exclude situations, variables or dates
filter_obs(
obs_list,
var = NULL,
situation = NULL,
dates = NULL,
include = FALSE,
var_names = lifecycle::deprecated(),
sit_names = lifecycle::deprecated()
)
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.
(optional, if not given all variables will be kept) Vector containing the names of the variables to include or exclude
(optional, if not given all situations will be kept) Vector containing the names of the situations to include or exclude
(optional, if not given all dates will be kept) Vector containing the dates (POSIXct format) to include or exclude
(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
obs_list List of filtered observed values (same format as obs_list
input argument)
For more detail and examples, see the different vignettes in CroptimizR website
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)
#> $sit1
#> Date var1
#> 1 2009-11-30 1.1
#> 2 2009-12-10 1.5
#>
#> $sit2
#> Date var1
#> 3 2009-11-30 1.3
#> 4 2009-12-05 2.0
#>
# Exclude observations at date "2009-11-30"
filter_obs(obs_list, dates = as.POSIXct(c("2009-11-30")))
#> $sit1
#> Date var1 var2
#> 1 2009-12-10 1.5 2.1
#>
#> $sit2
#> Date var1
#> 2 2009-12-05 2
#>