From 5edd100c3b70e8cbede6520661c399b54f1074b7 Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Fri, 18 Nov 2022 10:51:01 +0100 Subject: [PATCH 1/3] update length and docs --- R/choices_labeled.R | 10 +++++----- man/choices_labeled.Rd | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/choices_labeled.R b/R/choices_labeled.R index a3e1a8825..c4548d7fa 100644 --- a/R/choices_labeled.R +++ b/R/choices_labeled.R @@ -4,7 +4,7 @@ #' This is often useful for [choices_selected] as it marks up the dropdown boxes #' for [shiny::selectInput()]. #' -#' @param choices A character / factor / numeric / logical vector of length > 1. +#' @param choices A character / factor / numeric / logical vector. #' @param labels character vector containing labels to be applied to `choices`. If `NA` then #' "Label Missing" will be used. #' @param subset a vector that is a subset of `choices`. This is useful if @@ -61,10 +61,10 @@ choices_labeled <- function(choices, labels, subset = NULL, types = NULL) { } checkmate::assert( - checkmate::check_character(choices, min.len = 2, any.missing = FALSE), - checkmate::check_factor(choices, min.len = 2, any.missing = FALSE), - checkmate::check_numeric(choices, min.len = 2, any.missing = FALSE), - checkmate::check_logical(choices, min.len = 2, any.missing = FALSE) + checkmate::check_numeric(choices), + checkmate::check_character(choices), + checkmate::check_logical(choices), + checkmate::check_true(length(choices) == 1 && is.na(choices)) ) if (is.factor(labels)) { diff --git a/man/choices_labeled.Rd b/man/choices_labeled.Rd index 36a812fb2..d03d89381 100644 --- a/man/choices_labeled.Rd +++ b/man/choices_labeled.Rd @@ -10,7 +10,7 @@ choices_labeled(choices, labels, subset = NULL, types = NULL) \method{print}{choices_labeled}(x, ...) } \arguments{ -\item{choices}{A character / factor / numeric / logical vector of length > 1.} +\item{choices}{A character / factor / numeric / logical vector.} \item{labels}{character vector containing labels to be applied to \code{choices}. If \code{NA} then "Label Missing" will be used.} From 5fef961a1274ea7be093fe114690def6ecc443f8 Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal <86970066+mhallal1@users.noreply.github.com> Date: Fri, 18 Nov 2022 13:58:04 +0100 Subject: [PATCH 2/3] Update R/choices_labeled.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com> Signed-off-by: Mahmoud Hallal <86970066+mhallal1@users.noreply.github.com> --- R/choices_labeled.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/R/choices_labeled.R b/R/choices_labeled.R index c4548d7fa..a8193a9b9 100644 --- a/R/choices_labeled.R +++ b/R/choices_labeled.R @@ -61,10 +61,7 @@ choices_labeled <- function(choices, labels, subset = NULL, types = NULL) { } checkmate::assert( - checkmate::check_numeric(choices), - checkmate::check_character(choices), - checkmate::check_logical(choices), - checkmate::check_true(length(choices) == 1 && is.na(choices)) + checkmate::assert_atomic(choices, min.len = 1, any.missing = FALSE) ) if (is.factor(labels)) { From f76e9667d8cac35ee8b8cef144b8043f574ec375 Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Fri, 18 Nov 2022 14:21:42 +0100 Subject: [PATCH 3/3] update --- R/choices_labeled.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/choices_labeled.R b/R/choices_labeled.R index a8193a9b9..5a5461ea8 100644 --- a/R/choices_labeled.R +++ b/R/choices_labeled.R @@ -60,9 +60,7 @@ choices_labeled <- function(choices, labels, subset = NULL, types = NULL) { choices <- as.character(choices) } - checkmate::assert( - checkmate::assert_atomic(choices, min.len = 1, any.missing = FALSE) - ) + checkmate::assert_atomic(choices, min.len = 1, any.missing = FALSE) if (is.factor(labels)) { labels <- as.character(labels)