Skip to content

Commit

Permalink
no old Rd tags - partial
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Feb 7, 2024
1 parent 206c14e commit c5e475e
Show file tree
Hide file tree
Showing 21 changed files with 259 additions and 250 deletions.
153 changes: 77 additions & 76 deletions R/call_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@ call_check_parse_varname <- function(varname) {
#'
#' Compose choices condition call from inputs.
#'
#' @param varname (`name`, `call` or `character(1)`)\cr
#' name of the variable
#' @param varname (`name`, `call` or `character(1)`)
#' name of the variable
#' @param choices (`vector`)
#' `varname` values to match using the `==` (single value) or `%in%` (vector)
#' condition.
#' `choices` can be vector of any type but for some output might be converted:
#' * `factor` call is composed on choices converted to `character`
#' * `Date` call is composed on choices converted to `character` using
#' `format(choices)`
#' * `POSIXct`, `POSIXlt` Call is composed on choices converted to `character` using
#' `format(choices)`.
#'
#' One has to be careful here as formatted date-time variable might loose
#' some precision (see `format` argument in [format.POSIXlt()] and output call
#' could be insufficient for exact comparison. In this case one should specify
#' `varname = trunc(<varname>)` and possibly convert `choices` to `character`)
#'
#' @param choices (`vector`)\cr
#' `varname` values to match using the `==` (single value) or
#' `%in%` (vector) condition. `choices` can be vector of any type
#' but for some output might be converted:
#' \itemize{
#' \item{`factor`}{ call is composed on choices converted to `character`}
#' \item{`Date`}{ call is composed on choices converted to `character` using `format(choices)`}
#' \item{`POSIXct`, `POSIXlt`}{ Call is composed on choices converted to `character` using
#' `format(choices)`. One has to be careful here as formatted date-time variable might loose
#' some precision (see `format` argument in \code{\link{format.POSIXlt}}) and output call
#' could be insufficient for exact comparison. In this case one should specify
#' `varname = trunc(<varname>)` and possibly convert `choices` to `character`)
#' }
#' }
#' @return a `call`
#'
#' @examples
#' # use non-exported function from teal.transform
Expand All @@ -59,7 +60,6 @@ call_check_parse_varname <- function(varname) {
#' call_condition_choice("SEX", choices = factor(c("F", "M")))
#' call_condition_choice("x$SEX", choices = Sys.Date())
#' call_condition_choice("trunc(x$SEX)", choices = Sys.time())
#' @return a `call`
#' @keywords internal
#'
call_condition_choice <- function(varname, choices) {
Expand Down Expand Up @@ -92,13 +92,16 @@ call_condition_choice <- function(varname, choices) {
#'
#' Compose `numeric` range condition call from inputs
#'
#' @param varname (`name` or `character(1)`)\cr
#' name of the variable
#' @param varname (`name` or `character(1)`)
#'
#' @param range (`numeric(2)`)\cr
#' range of the variable
#' name of the variable
#'
#' @param range (`numeric(2)`)
#'
#' range of the variable
#'
#' @return a `call`
#'
#' @return call
#' @examples
#' # use non-exported function from teal.transform
#' call_condition_range <- getFromNamespace("call_condition_range", "teal.transform")
Expand All @@ -110,7 +113,6 @@ call_condition_choice <- function(varname, choices) {
#' call_extract_list("ADSL", "AGE"),
#' range = c(-1.2, 2.1)
#' )
#' @return a `call`
#' @keywords internal
#'
call_condition_range <- function(varname, range) {
Expand All @@ -128,20 +130,22 @@ call_condition_range <- function(varname, range) {
#'
#' Compose `logical` variable condition call from inputs
#'
#' @param varname (`name` or `character(1)`)\cr
#' name of the variable
#' @param varname (`name` or `character(1)`)
#'
#' name of the variable
#'
#' @param choice (`logical(1)`)\cr
#' chosen value
#' @param choice (`logical(1)`)
#'
#' chosen value
#'
#' @return a `call`
#'
#' @return call
#' @examples
#' # use non-exported function from teal.transform
#' call_condition_logical <- getFromNamespace("call_condition_logical", "teal.transform")
#'
#' call_condition_logical("event", choice = TRUE)
#' call_condition_logical("event", choice = FALSE)
#' @return a `call`
#' @keywords internal
#'
call_condition_logical <- function(varname, choice) {
Expand All @@ -165,17 +169,16 @@ call_condition_logical <- function(varname, choice) {
#'
#' Compose `POSIXct` range condition call from inputs.
#'
#' @param varname (`name` or `character(1)`)\cr
#' name of the variable
#' @param varname (`name` or `character(1)`)
#' name of the variable
#'
#' @param range (`POSIXct`)\cr
#' range of the variable. Be aware that output
#' uses truncated range format `"%Y-%m-%d %H:%M:%S"`, which means that
#' some precision might be lost.
#' @param range (`POSIXct`)
#' range of the variable. Be aware that output uses truncated range format
#' `"%Y-%m-%d %H:%M:%S"`, which means that some precision might be lost.
#'
#' @param timezone (`character(1)`)\cr
#' specifies the time zone to be used for the conversion.
#' By default `Sys.timezone()` is used.
#' @param timezone (`character(1)`)
#' specifies the time zone to be used for the conversion.
#' By default `Sys.timezone()` is used.
#'
#' @examples
#' # use non-exported function from teal.transform
Expand Down Expand Up @@ -216,11 +219,13 @@ call_condition_range_posixct <- function(varname, range, timezone = Sys.timezone
#'
#' Compose `Date` range condition call from inputs
#'
#' @param varname (`name` or `character(1)`)\cr
#' name of the variable
#' @param varname (`name` or `character(1)`)
#' name of the variable
#'
#' @param range (`Date`)\cr
#' range of the variable
#' @param range (`Date`)
#' range of the variable
#'
#' @return a `call`
#'
#' @examples
#' # use non-exported function from teal.transform
Expand All @@ -230,7 +235,6 @@ call_condition_range_posixct <- function(varname, range, timezone = Sys.timezone
#' as.name("date"),
#' range = c(Sys.Date(), Sys.Date() + 1)
#' )
#' @return a `call`
#' @keywords internal
#'
call_condition_range_date <- function(varname, range) {
Expand All @@ -247,15 +251,16 @@ call_condition_range_date <- function(varname, range) {

#' Get call to subset and select array
#'
#' Get call to subset and select array
#' @param dataname (`character(1)` or `name`)\cr
#' @param row (`name`, `call`, `logical`, `integer`, `character`)\cr
#' optional, name of the `row` or condition
#' @param column (`name`, `call`, `logical`, `integer`, `character`)\cr
#' optional, name of the `column` or condition
#' @param aisle (`name`, `call`, `logical`, `integer`, `character`)\cr
#' optional, name of the `row` or condition
#' @return `[` call with all conditions included
#' @param dataname (`character(1)` or `name`)
#' @param row (`name`, `call`, `logical`, `integer`, `character`)
#' optional, name of the `row` or condition
#' @param column (`name`, `call`, `logical`, `integer`, `character`)
#' optional, name of the `column` or condition
#' @param aisle (`name`, `call`, `logical`, `integer`, `character`)
#' optional, name of the `row` or condition
#'
#' @return specific [Extract()] `call` for 3-dimensional array
#'
#' @examples
#' # use non-exported function from teal.transform
#' call_extract_array <- getFromNamespace("call_extract_array", "teal.transform")
Expand All @@ -271,7 +276,6 @@ call_condition_range_date <- function(varname, range) {
#' "mae_object",
#' column = call_condition_choice("SEX", "M")
#' )
#' @return specific \code{\link[base]{Extract}} `call` for 3-dimensional array
#' @keywords internal
#'
call_extract_array <- function(dataname = ".", row = NULL, column = NULL, aisle = NULL) {
Expand Down Expand Up @@ -312,13 +316,14 @@ call_extract_array <- function(dataname = ".", row = NULL, column = NULL, aisle

#' Get call to subset and select matrix
#'
#' Get call to subset and select matrix
#' @param dataname (`character(1)` or `name`)\cr
#' @param row (`name`, `call`, `logical`, `integer`, `character`)\cr
#' optional, name of the `row` or condition
#' @param column (`name`, `call`, `logical`, `integer`, `character`)\cr
#' optional, name of the `column` or condition
#' @return `[` call with all conditions included
#' @param dataname (`character(1)` or `name`)
#' @param row (`name`, `call`, `logical`, `integer`, `character`)
#' optional, name of the `row` or condition
#' @param column (`name`, `call`, `logical`, `integer`, `character`)
#' optional, name of the `column` or condition
#'
#' @return specific [Extract()] `call` for matrix
#'
#' @examples
#' # use non-exported function from teal.transform
#' call_extract_matrix <- getFromNamespace("call_extract_matrix", "teal.transform")
Expand All @@ -333,7 +338,6 @@ call_extract_array <- function(dataname = ".", row = NULL, column = NULL, aisle
#' "mae_object",
#' column = call_condition_choice("SEX", "M")
#' )
#' @return specific \code{\link[base]{Extract}} `call` for matrix
#' @keywords internal
#'
call_extract_matrix <- function(dataname = ".", row = NULL, column = NULL) {
Expand Down Expand Up @@ -369,18 +373,15 @@ call_extract_matrix <- function(dataname = ".", row = NULL, column = NULL) {

#' Compose extract call with `$` operator
#'
#' Compose extract call with `$` operator
#'
#' @param dataname (`character(1)` or `name`)\cr
#' name of the object
#'
#' @param varname (`character(1)` or `name`)\cr
#' name of the slot in data
#'
#' @param dataname (`character(1)` or `name`)
#' name of the object
#' @param varname (`character(1)` or `name`)
#' name of the slot in data
#' @param dollar (`logical(1)`)\cr
#' whether returned call should use `$` or `[[` operator
#' whether returned call should use `$` or `[[` operator
#'
#' @return `$` or `[[` call
#'
#' @examples
#' # use non-exported function from teal.transform
#' call_extract_list <- getFromNamespace("call_extract_list", "teal.transform")
Expand Down Expand Up @@ -474,13 +475,14 @@ call_with_colon <- function(name, ..., unlist_args = list()) {
#'
#' Combine list of calls by specific operator
#'
#' @param operator (`character(1)` or `name`)\cr
#' name/symbol of the operator.
#' @param operator (`character(1)` or `name`)
#' name / symbol of the operator.
#'
#' @param calls (`list` of calls)
#' list containing calls to be combined by `operator`
#'
#' @param calls (`list` of calls)\cr
#' list containing calls to be combined by `operator`
#' @return a combined `call`
#'
#' @return call
#' @examples
#' # use non-exported function from teal.transform
#' calls_combine_by <- getFromNamespace("calls_combine_by", "teal.transform")
Expand All @@ -496,7 +498,6 @@ call_with_colon <- function(name, ..., unlist_args = list()) {
#' TRUE
#' )
#' )
#' @return a combined `call`
#' @keywords internal
#'
calls_combine_by <- function(operator, calls) {
Expand Down
30 changes: 16 additions & 14 deletions R/choices_selected.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ no_select_keyword <- "-- no selection --"
#' or whether to block the user from making selections. Can be used in `ui` input elements
#' such as [teal.widgets::optionalSelectInput()]
#'
#' @param choices (`character`) vector of possible choices or `delayed_data` object\cr
#' See [variable_choices()] and [value_choices()].
#' @param choices (`character`) vector of possible choices or `delayed_data` object
#'
#' See [variable_choices()] and [value_choices()].
#' @param selected (`character`) vector of preselected options, (`all_choices`) object
#' or (`delayed_data`) object. If `delayed_data` object then `choices` must also be
#' a `delayed_data` object. If not supplied it will default to the first element of
#' `choices` if `choices` is a vector, or `NULL` if `choices` is a `delayed_data` object.
#' @param keep_order (`logical`)\cr
#' In case of `FALSE` the selected variables will be on top of the drop-down field.
#' @param fixed optional, (`logical`)\cr
#' Whether to block user to select choices
#' or (`delayed_data`) object.
#'
#' If `delayed_data` object then `choices` must also be `delayed_data` object.
#' If not supplied it will default to the first element of `choices` if
#' `choices` is a vector, or `NULL` if `choices` is a `delayed_data` object.
#' @param keep_order (`logical`)
#' In case of `FALSE` the selected variables will be on top of the drop-down field.
#' @param fixed optional, (`logical`)
#' Whether to block user to select choices
#'
#' @details
#'
Expand Down Expand Up @@ -183,8 +186,8 @@ is.choices_selected <- function(x) { # nolint
#'
#' @description `r lifecycle::badge("stable")`
#'
#' @param x (\code{choices_selected}) output
#' @param multiple (\code{logical}) whether multiple selections are allowed or not
#' @param x (`choices_selected`) output
#' @param multiple (`logical`) whether multiple selections are allowed or not
#'
#' @export
add_no_selected_choices <- function(x, multiple = FALSE) {
Expand All @@ -206,10 +209,9 @@ add_no_selected_choices <- function(x, multiple = FALSE) {
#'
#' @description `r lifecycle::badge("stable")`
#'
#' @param x (\code{character}) Word that shall be checked for
#' NULL, empty, "--no-selection"
#' @param x (`character`) Word that shall be checked for `NULL`, empty, "--no-selection"
#'
#' @return the word or NULL
#' @return the word or `NULL`
#'
#' @export
no_selected_as_NULL <- function(x) { # nolint
Expand Down
8 changes: 4 additions & 4 deletions R/column_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#' @description `r lifecycle::badge("stable")`
#' @export
#'
#' @param data (\code{data.frame}) Data with attribute \code{filter_and_columns}. This can only be
#' created by \code{\link{data_extract_srv}}. which returns a shiny \code{\link[shiny]{reactive}}.
#' @param data (`data.frame`) Data with attribute `filter_and_columns`. This can only be
#' created by [data_extract_srv()]. which returns a shiny [shiny::reactive()].
#'
#' @return A named character vector with the non-key columns of the \code{data}..
#' @return A named character vector with the non-key columns of the `data`.
#'
#' @references \link{data_extract_srv}
#' @references [data_extract_srv]
get_dataset_prefixed_col_names <- function(data) {
if (!is.null(attr(data, "filter_and_columns")$columns) && attr(data, "filter_and_columns")$columns != "") {
paste(attr(data, "dataname"), attr(data, "filter_and_columns")$columns, sep = ".")
Expand Down
24 changes: 17 additions & 7 deletions R/data_extract_datanames.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#' Available datasets input
#'
#' @description `r lifecycle::badge("stable")`
#' @description
#' `r lifecycle::badge("stable")`
#'
#' Creates \link[shiny]{helpText} with the names of datasets
#' available for current module.
#'
#' @param data_extracts list of data extracts for single variable
#'
#' @export
datanames_input <- function(data_extracts) {
datanames <- get_extract_datanames(data_extracts)
Expand All @@ -15,11 +19,14 @@ datanames_input <- function(data_extracts) {

#' Gets names of the datasets from a list of `data_extract_spec` objects
#'
#' @description `r lifecycle::badge("stable")`
#' Fetches `dataname` slot per \code{data_extract_spec} from a list of \code{data_extract_spec}
#' and returns the unique `dataname` set.
#' @description
#' `r lifecycle::badge("stable")`
#'
#' Fetches `dataname` slot per `data_extract_spec` from a list of
#' `data_extract_spec` and returns the unique `dataname` set.
#'
#' @param data_extracts A single \code{data_extract_spec} object or a list (of lists) of \code{data_extract_spec}
#' @param data_extracts A single `data_extract_spec` object or a list (of lists)
#' of `data_extract_spec`
#'
#' @export
get_extract_datanames <- function(data_extracts) {
Expand Down Expand Up @@ -53,10 +60,13 @@ get_extract_datanames <- function(data_extracts) {

#' Checks if the input `data_extract_spec` objects all come from the same dataset
#'
#' @description `r lifecycle::badge("stable")`
#' @param ... either \code{data_extract_spec} objects or lists of \code{data_extract_spec} objects that do not contain
#' `r lifecycle::badge("stable")`
#'
#' @param ... either `data_extract_spec` objects or lists of `data_extract_spec` objects that do not contain
#' NULL
#'
#' @return logical
#'
#' @export
is_single_dataset <- function(...) {
data_extract_spec <- list(...)
Expand Down
Loading

0 comments on commit c5e475e

Please sign in to comment.