diff --git a/R/tar_nlmixr.R b/R/tar_nlmixr.R index e5e15df..b5ca1af 100644 --- a/R/tar_nlmixr.R +++ b/R/tar_nlmixr.R @@ -79,8 +79,6 @@ tar_nlmixr_raw <- function(name, object, data, est, control, table, object_simpl checkmate::assert_character(object_simple_name, len = 1, min.chars = 1, any.missing = FALSE) checkmate::assert_character(data_simple_name, len = 1, min.chars = 1, any.missing = FALSE) - # Make models with initial conditions set work within `targets` (see #15) - set_env_object_noinitial(object = object, env = env) list( object_simple = targets::tar_target_raw( @@ -143,31 +141,6 @@ tar_nlmixr_raw <- function(name, object, data, est, control, table, object_simpl ) } -#' Ensure that an object is set in its initial environment so that it is -#' protected from the `targets` domain-specific-language issue of -#' `pd(0) <- initial` -#' -#' @inheritParams tar_nlmixr -#' @return NULL (called for side effects) -#' @noRd -set_env_object_noinitial <- function(object, env) { - if (is.name(object)) { - object_env <- env[[as.character(object)]] - if (is.function(object_env)) { - object_result <- try(rxode2::assertRxUi(object_env), silent = TRUE) - if (inherits(object_result, "rxUi")) { - assign(x = as.character(object), value = object_result, envir = env) - } - } - } else if (is.call(object)) { - # Recursively iterate over all parts of the call - lapply(X = object, FUN = set_env_object_noinitial, env = env) - } - # If it's anything other than a name or a call, then we don't need to modify - # it or its sub-objects. - NULL -} - #' Replace the fit data with the original data, then return the modified fit #' #' This function is intended for use within `nlmixr2targets` target creation,