diff options
author | Ranke Johannes <johannes.ranke@agroscope.admin.ch> | 2024-12-19 10:59:44 +0100 |
---|---|---|
committer | Ranke Johannes <johannes.ranke@agroscope.admin.ch> | 2024-12-19 10:59:44 +0100 |
commit | e5aea600fd957955fc3e8e41dbc93bf4f65af803 (patch) | |
tree | fe72d2b020b50307944f616333df7419e07393e1 /R | |
parent | 7b14afbeaa779009014ee866fe5e56edd3e8681d (diff) |
Support observed data as tibble
Closes #14
Diffstat (limited to 'R')
-rw-r--r-- | R/mkinfit.R | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R index c851fddb..52053685 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -21,7 +21,8 @@ utils::globalVariables(c("name", "time", "value")) #' "FOMC", "DFOP", "HS", "SFORB", "IORE"). If a shorthand name is given, a #' parent only degradation model is generated for the variable with the #' highest value in \code{observed}. -#' @param observed A dataframe with the observed data. The first column called +#' @param observed A dataframe or an object coercible to a dataframe +#' (e.g. a \code{tibble}) with the observed data. The first column called #' "name" must contain the name of the observed variable for each data point. #' The second column must contain the times of observation, named "time". #' The third column must be named "value" and contain the observed values. @@ -292,6 +293,9 @@ mkinfit <- function(mkinmod, observed, # Get the names of observed variables obs_vars <- names(mkinmod$spec) + # Coerce observed data to a dataframe + observed <- as.data.frame(observed) + # Subset observed data with names of observed data in the model and remove NA values observed <- subset(observed, name %in% obs_vars) observed <- subset(observed, !is.na(value)) |