From f053382d672c2ae3ef8bf7adf727f76857d49035 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 16 Sep 2024 09:21:39 -0400 Subject: [PATCH] rename prediction column (closes #22) --- R/adjust-numeric-range.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/R/adjust-numeric-range.R b/R/adjust-numeric-range.R index b494939..c82276b 100644 --- a/R/adjust-numeric-range.R +++ b/R/adjust-numeric-range.R @@ -14,7 +14,6 @@ #' @inheritSection adjust_equivocal_zone Data Usage #' #' @examplesIf FALSE -# # TODO: unskip -- fn currently requires estimate to be called `.pred` (#22) #' library(tibble) #' #' # create example data @@ -105,12 +104,21 @@ predict.numeric_range <- function(object, new_data, tailor, ...) { lo <- object$arguments$lower_limit hi <- object$arguments$upper_limit - # todo depends on tm predict col names new_data[[est_nm]] <- - probably::bound_prediction(new_data, lower_limit = lo, upper_limit = hi)[[est_nm]] + probably::bound_prediction( + rename_prediction_column(new_data, est_nm), + lower_limit = lo, + upper_limit = hi + )[[".pred"]] new_data } +rename_prediction_column <- function(data, est_nm) { + data[[".pred"]] <- data[[est_nm]] + data[[est_nm]] <- NULL + data +} + #' @export required_pkgs.numeric_range <- function(x, ...) { c("tailor", "probably")