From ffeec54a798fb15192ec4e1ff23b5518344b0bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:00:57 +0100 Subject: [PATCH 1/6] docs: update tm_g_response for pre-release --- R/tm_g_response.R | 53 +++++++++++++++++++++++++++++--------------- man/tm_g_response.Rd | 45 ++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 33 deletions(-) diff --git a/R/tm_g_response.R b/R/tm_g_response.R index 517c80edd..6ef589b88 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -1,28 +1,43 @@ -#' Response Plots -#' @md +#' Response plot module +#' +#' Generates a response plot for a given `response` and `x` variables. +#' This module allows users customize and add annotations to the plot depending +#' via the module's arguments. +#' It supports showing the counts grouped by other variable facets (by row / column), +#' swapping the coordinates, show count annotations and displaying the response plot +#' as frequency or density. #' #' @inheritParams teal::module #' @inheritParams shared_params #' @param response (`data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Which variable to use as the response. You can define one fixed column by using the -#' setting `fixed = TRUE` inside the `select_spec`. -#' `data_extract_spec` must not allow multiple selection in this case. +#' Which variable to use as the response. +#' You can define one fixed column by using the setting `fixed = TRUE` inside the `select_spec`. +#' +#' The `data_extract_spec` must not allow multiple selection in this case. #' @param x (`data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Which variable to use on the X-axis of the response plot. Allow the user to select multiple -#' columns from the `data` allowed in teal. -#' `data_extract_spec` must not allow multiple selection in this case. -#' @param row_facet optional, (`data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Which data columns to use for faceting rows. -#' @param col_facet optional, (`data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Which data to use for faceting columns. -#' @param coord_flip optional, (`logical`) Whether to flip coordinates between `x` and `response`. -#' @param count_labels optional, (`logical`) Whether to show count labels. -#' Defaults to `TRUE`. -#' @param freq optional, (`logical`) Whether to display frequency (`TRUE`) or density (`FALSE`). -#' Defaults to density (`FALSE`). +#' Specifies which variable to use on the X-axis of the response plot. +#' Allow the user to select multiple columns from the `data` allowed in teal. +#' +#' The `data_extract_spec` must not allow multiple selection in this case. +#' @param row_facet (optional `data_extract_spec` or `list` of multiple `data_extract_spec`) +#' Specifies the data variable(s) to use for faceting rows. +#' @param col_facet (optional `data_extract_spec` or `list` of multiple `data_extract_spec`) +#' Specifies the data variable(s) to use for faceting columns. +#' @param coord_flip (optional `logical`) +#' Indicates whether to flip coordinates between `x` and `response`. +#' The default value is `FALSE` and it will show the `x` variable on the x-axis +#' and the `response` variable on the y-axis. +#' @param count_labels (optional `logical`) +#' Indicates whether to show count labels. +#' Defaults to `TRUE`. +#' @param freq (optional `logical`) +#' Indicates whether to display frequency (`TRUE`) or density (`FALSE`). +#' Defaults to density (`FALSE`). +#' +#' @return Object of class `teal_module` to be used in `teal` applications. #' #' @note For more examples, please see the vignette "Using response plot" via -#' \code{vignette("using-response-plot", package = "teal.modules.general")}. +#' `vignette("using-response-plot", package = "teal.modules.general")`. #' #' @examples #' # general data example @@ -195,6 +210,7 @@ tm_g_response <- function(label = "Response Plot", ) } +# UI function for the response module ui_g_response <- function(id, ...) { ns <- NS(id) args <- list(...) @@ -270,6 +286,7 @@ ui_g_response <- function(id, ...) { ) } +# Server function for the response module srv_g_response <- function(id, data, reporter, diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index 71d994bb6..7d3d6ae0e 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/tm_g_response.R \name{tm_g_response} \alias{tm_g_response} -\title{Response Plots} +\title{Response plot module} \usage{ tm_g_response( label = "Response Plot", @@ -27,30 +27,37 @@ tm_g_response( For \code{modules()} defaults to \code{"root"}. See \code{Details}.} \item{response}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Which variable to use as the response. You can define one fixed column by using the -setting \code{fixed = TRUE} inside the \code{select_spec}. -\code{data_extract_spec} must not allow multiple selection in this case.} +Which variable to use as the response. +You can define one fixed column by using the setting \code{fixed = TRUE} inside the \code{select_spec}. + +The \code{data_extract_spec} must not allow multiple selection in this case.} \item{x}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Which variable to use on the X-axis of the response plot. Allow the user to select multiple -columns from the \code{data} allowed in teal. -\code{data_extract_spec} must not allow multiple selection in this case.} +Specifies which variable to use on the X-axis of the response plot. +Allow the user to select multiple columns from the \code{data} allowed in teal. + +The \code{data_extract_spec} must not allow multiple selection in this case.} -\item{row_facet}{optional, (\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Which data columns to use for faceting rows.} +\item{row_facet}{(optional \code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) +Specifies the data variable(s) to use for faceting rows.} -\item{col_facet}{optional, (\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Which data to use for faceting columns.} +\item{col_facet}{(optional \code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) +Specifies the data variable(s) to use for faceting columns.} -\item{coord_flip}{optional, (\code{logical}) Whether to flip coordinates between \code{x} and \code{response}.} +\item{coord_flip}{(optional \code{logical}) +Indicates whether to flip coordinates between \code{x} and \code{response}. +The default value is \code{FALSE} and it will show the \code{x} variable on the x-axis +and the \code{response} variable on the y-axis.} -\item{count_labels}{optional, (\code{logical}) Whether to show count labels. +\item{count_labels}{(optional \code{logical}) +Indicates whether to show count labels. Defaults to \code{TRUE}.} \item{rotate_xaxis_labels}{optional, (\code{logical}) Whether to rotate plot X axis labels. Does not rotate by default (\code{FALSE}).} -\item{freq}{optional, (\code{logical}) Whether to display frequency (\code{TRUE}) or density (\code{FALSE}). +\item{freq}{(optional \code{logical}) +Indicates whether to display frequency (\code{TRUE}) or density (\code{FALSE}). Defaults to density (\code{FALSE}).} \item{plot_height}{optional, (\code{numeric}) A vector of length three with \verb{c(value, min and max)} @@ -73,8 +80,16 @@ with text placed before the output to put the output into context. For example a \item{post_output}{(\code{shiny.tag}, optional) with text placed after the output to put the output into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} } +\value{ +Object of class \code{teal_module} to be used in \code{teal} applications. +} \description{ -Response Plots +Generates a response plot for a given \code{response} and \code{x} variables. +This module allows users customize and add annotations to the plot depending +via the module's arguments. +It supports showing the counts grouped by other variable facets (by row / column), +swapping the coordinates, show count annotations and displaying the response plot +as frequency or density. } \note{ For more examples, please see the vignette "Using response plot" via From 8815206b988c4ac2931e7706325503706ed29786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:48:43 +0100 Subject: [PATCH 2/6] docs: inherit return tag --- R/tm_g_response.R | 2 +- man/tm_g_response.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_g_response.R b/R/tm_g_response.R index 6ef589b88..14753a710 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -34,7 +34,7 @@ #' Indicates whether to display frequency (`TRUE`) or density (`FALSE`). #' Defaults to density (`FALSE`). #' -#' @return Object of class `teal_module` to be used in `teal` applications. +#' @inherit shared_params return #' #' @note For more examples, please see the vignette "Using response plot" via #' `vignette("using-response-plot", package = "teal.modules.general")`. diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index 7d3d6ae0e..80cdb05d1 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -81,7 +81,7 @@ with text placed before the output to put the output into context. For example a into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} } \value{ -Object of class \code{teal_module} to be used in \code{teal} applications. +Object of class \code{teal_module} to be used in \code{teal} applications } \description{ Generates a response plot for a given \code{response} and \code{x} variables. From 62eb8ea507854ce9e95d1bfa40bd67e24e59f4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:11:53 +0100 Subject: [PATCH 3/6] docs: update docs --- man/tm_g_response.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index 80cdb05d1..7d3d6ae0e 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -81,7 +81,7 @@ with text placed before the output to put the output into context. For example a into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} } \value{ -Object of class \code{teal_module} to be used in \code{teal} applications +Object of class \code{teal_module} to be used in \code{teal} applications. } \description{ Generates a response plot for a given \code{response} and \code{x} variables. From 2d9fc9c882fdac1fee86d70af8a904164b017a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:44:25 +0100 Subject: [PATCH 4/6] docs: update notation with optional string --- R/tm_g_response.R | 14 +++++++------- man/tm_g_response.Rd | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/R/tm_g_response.R b/R/tm_g_response.R index 739144350..f38be24d6 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -19,18 +19,18 @@ #' Allow the user to select multiple columns from the `data` allowed in teal. #' #' The `data_extract_spec` must not allow multiple selection in this case. -#' @param row_facet (optional `data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Specifies the data variable(s) to use for faceting rows. -#' @param col_facet (optional `data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Specifies the data variable(s) to use for faceting columns. -#' @param coord_flip (optional `logical`) +#' @param row_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`) +#' optional specification of the data variable(s) to use for faceting rows. +#' @param col_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`) +#' optional specification of the data variable(s) to use for faceting columns. +#' @param coord_flip (`logical(1)`) #' Indicates whether to flip coordinates between `x` and `response`. #' The default value is `FALSE` and it will show the `x` variable on the x-axis #' and the `response` variable on the y-axis. -#' @param count_labels (optional `logical`) +#' @param count_labels (`logical(1)`) #' Indicates whether to show count labels. #' Defaults to `TRUE`. -#' @param freq (optional `logical`) +#' @param freq (`logical(1)`) #' Indicates whether to display frequency (`TRUE`) or density (`FALSE`). #' Defaults to density (`FALSE`). #' diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index aa2d24fc2..22ca66ded 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -38,25 +38,25 @@ Allow the user to select multiple columns from the \code{data} allowed in teal. The \code{data_extract_spec} must not allow multiple selection in this case.} -\item{row_facet}{(optional \code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Specifies the data variable(s) to use for faceting rows.} +\item{row_facet}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) +optional specification of the data variable(s) to use for faceting rows.} -\item{col_facet}{(optional \code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Specifies the data variable(s) to use for faceting columns.} +\item{col_facet}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) +optional specification of the data variable(s) to use for faceting columns.} -\item{coord_flip}{(optional \code{logical}) +\item{coord_flip}{(\code{logical(1)}) Indicates whether to flip coordinates between \code{x} and \code{response}. The default value is \code{FALSE} and it will show the \code{x} variable on the x-axis and the \code{response} variable on the y-axis.} -\item{count_labels}{(optional \code{logical}) +\item{count_labels}{(\code{logical(1)}) Indicates whether to show count labels. Defaults to \code{TRUE}.} \item{rotate_xaxis_labels}{optional, (\code{logical}) Whether to rotate plot X axis labels. Does not rotate by default (\code{FALSE}).} -\item{freq}{(optional \code{logical}) +\item{freq}{(\code{logical(1)}) Indicates whether to display frequency (\code{TRUE}) or density (\code{FALSE}). Defaults to density (\code{FALSE}).} From 55180d09f60245885ab2108d957c0725fcc44c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:34:16 +0100 Subject: [PATCH 5/6] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vedha Viyash <49812166+vedhav@users.noreply.github.com> Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> --- R/tm_g_response.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_g_response.R b/R/tm_g_response.R index f38be24d6..52c221e7e 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -2,7 +2,7 @@ #' #' Generates a response plot for a given `response` and `x` variables. #' This module allows users customize and add annotations to the plot depending -#' via the module's arguments. +#' on the module's arguments. #' It supports showing the counts grouped by other variable facets (by row / column), #' swapping the coordinates, show count annotations and displaying the response plot #' as frequency or density. @@ -11,7 +11,7 @@ #' @inheritParams shared_params #' @param response (`data_extract_spec` or `list` of multiple `data_extract_spec`) #' Which variable to use as the response. -#' You can define one fixed column by using the setting `fixed = TRUE` inside the `select_spec`. +#' You can define one fixed column by setting `fixed = TRUE` inside the `select_spec`. #' #' The `data_extract_spec` must not allow multiple selection in this case. #' @param x (`data_extract_spec` or `list` of multiple `data_extract_spec`) From 2a8977d5005b8a5db1f9872eef202fc7095899ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:34:42 +0100 Subject: [PATCH 6/6] docs: update documentation --- man/tm_g_response.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index 22ca66ded..74c6b40ac 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -28,7 +28,7 @@ For \code{modules()} defaults to \code{"root"}. See \code{Details}.} \item{response}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) Which variable to use as the response. -You can define one fixed column by using the setting \code{fixed = TRUE} inside the \code{select_spec}. +You can define one fixed column by setting \code{fixed = TRUE} inside the \code{select_spec}. The \code{data_extract_spec} must not allow multiple selection in this case.} @@ -86,7 +86,7 @@ Object of class \code{teal_module} to be used in \code{teal} applications. \description{ Generates a response plot for a given \code{response} and \code{x} variables. This module allows users customize and add annotations to the plot depending -via the module's arguments. +on the module's arguments. It supports showing the counts grouped by other variable facets (by row / column), swapping the coordinates, show count annotations and displaying the response plot as frequency or density.