From 338b21ce72791cf75e17a900008952783762eb5c Mon Sep 17 00:00:00 2001 From: bluefoxr Date: Tue, 21 May 2024 16:35:47 +0200 Subject: [PATCH] small updates --- man/Treat.purse.Rd | 4 ++++ man/n_scaled.Rd | 8 +++++--- tests/testthat/test-treat.R | 13 +++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/man/Treat.purse.Rd b/man/Treat.purse.Rd index 91c3d610..3e3af3c2 100644 --- a/man/Treat.purse.Rd +++ b/man/Treat.purse.Rd @@ -11,6 +11,7 @@ indiv_specs = NULL, combine_treat = FALSE, write_to = NULL, + disable = FALSE, ... ) } @@ -29,6 +30,9 @@ of \code{f1}, so the two treatments will be combined.} \item{write_to}{If specified, writes the aggregated data to \code{.$Data[[write_to]]}. Default \code{write_to = "Treated"}.} +\item{disable}{Logical: if \code{TRUE} will disable data treatment completely and write the unaltered data set. This option is mainly useful +in sensitivity and uncertainty analysis (to test the effect of turning imputation on/off).} + \item{...}{arguments passed to or from other methods.} } \value{ diff --git a/man/n_scaled.Rd b/man/n_scaled.Rd index 54a82337..7d610eb8 100644 --- a/man/n_scaled.Rd +++ b/man/n_scaled.Rd @@ -4,24 +4,26 @@ \alias{n_scaled} \title{Scale a vector} \usage{ -n_scaled(x, npara = c(0, 100)) +n_scaled(x, npara = c(0, 100), scale_factor = 100) } \arguments{ \item{x}{A numeric vector} \item{npara}{Parameters as a vector \code{c(l, u)}. See description.} + +\item{scale_factor}{Optional scaling factor to apply to the result. Default 100.} } \value{ Scaled vector } \description{ Scales a vector for normalisation using the method applied in the GII2020 for some indicators. This -does \code{x_scaled <- (x-l)/(u-l) * 100}. Note this is \emph{not} the minmax transformation (see \code{\link[=n_minmax]{n_minmax()}}). +does \code{x_scaled <- (x-l)/(u-l) * scale_factor}. Note this is \emph{not} the minmax transformation (see \code{\link[=n_minmax]{n_minmax()}}). This is a linear transformation with shift \code{u} and scaling factor \code{u-l}. } \details{ This function also supports parameter specification in \code{iMeta} for the \code{\link[=Normalise.coin]{Normalise.coin()}} method. -To do this, add columns \code{scaled_lower}, and \code{scaled_upper} to the \code{iMeta} table, which specify the +To do this, add columns \code{scaled_lower}, \code{scaled_upper} and \code{scale_factor} to the \code{iMeta} table, which specify the first and second elements of \code{npara}, respectively. Then set \code{f_n_para = "use_iMeta"} within the \code{global_specs} list. See also examples in the \href{https://bluefoxr.github.io/COINr/articles/normalise.html}{normalisation vignette}. } diff --git a/tests/testthat/test-treat.R b/tests/testthat/test-treat.R index ac40705d..fdcd1358 100644 --- a/tests/testthat/test-treat.R +++ b/tests/testthat/test-treat.R @@ -78,3 +78,16 @@ test_that("treat_coin", { expect_identical(dset_t, dset_t2$x_treat) }) + +test_that("disable_treat", { + + purse <- build_example_purse(up_to = "Screen", quietly = T) + + purse <- Treat(purse, dset = "Screened", disable = T) + + d1 <- get_dset(purse, dset = "Treated") + d2 <- get_dset(purse, dset = "Screened") + + expect_equal(d1, d2) + +})