Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pre-release@main' into 686-asser…
Browse files Browse the repository at this point in the history
…tions_process@pre-release@main

* origin/pre-release@main:
  removed @nord tags and added return from shared_params
  missing comma
  641 non exported functions (#680)
  pre-release vignettes review (#681)
  [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
  Standardise function titles similar to what we have in tmc (#691)
  [skip actions] Bump version to 0.2.16.9026
  `tm_g_regression` labels are no longer allowed out of bounds (#675)
  [skip actions] Bump version to 0.2.16.9025
  Remove the internal function `var_labels` in favour of `teal.data::col_labels` (#690)
  [skip actions] Bump version to 0.2.16.9024
  Fix the silent error in `tm_a_pca` (#688)
  • Loading branch information
averissimo committed Feb 28, 2024
2 parents 4e3f7fc + 87f6eee commit f164561
Show file tree
Hide file tree
Showing 64 changed files with 2,555 additions and 2,498 deletions.
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL
object_usage_linter = NULL,
object_name_linter = object_name_linter(styles = c("snake_case", "symbols"), regexes = c(ANL = "^ANL_?[0-9]*$", ADaM = "^r?AD[A-Z]{2,3}_?[0-9]*$"))
)
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ repos:
- dplyr
- DT
- forcats
- ggrepel
- grid
- logger
- scales
Expand Down
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: teal.modules.general
Title: General Modules for 'teal' Applications
Version: 0.2.16.9023
Date: 2024-02-22
Version: 0.2.16.9026
Date: 2024-02-27
Authors@R: c(
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")),
person("Pawel", "Rucki", , "pawel.rucki@roche.com", role = "aut"),
Expand Down Expand Up @@ -59,6 +59,7 @@ Suggests:
ggExtra,
ggpmisc (>= 0.4.3),
ggpp,
ggrepel,
goftest,
gridExtra,
htmlwidgets,
Expand All @@ -84,9 +85,10 @@ Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2,
insightsengineering/teal.widgets, insightsengineering/tern,
tidyverse/tibble, tidyverse/tidyr, tidymodels/broom,
daattali/colourpicker, daattali/ggExtra, aphalo/ggpmisc, aphalo/ggpp,
baddstats/goftest, gridExtra, ramnathv/htmlwidgets, jeroen/jsonlite,
yihui/knitr, deepayan/lattice, MASS, insightsengineering/nestcolor,
r-lib/rlang, insightsengineering/rtables, htmlwidgets/sparkline,
slowkow/ggrepel, baddstats/goftest, gridExtra, ramnathv/htmlwidgets,
jeroen/jsonlite, yihui/knitr, deepayan/lattice, MASS,
insightsengineering/nestcolor, r-lib/rlang,
insightsengineering/rtables, sparkline, insightsengineering/teal.data,
r-lib/testthat
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# teal.modules.general 0.2.16.9023
# teal.modules.general 0.2.16.9026

### Enhancements

* Updated the package docs and vignettes with the new way of specifying data for `teal::init()`. The `data` argument will accept a `teal_data` object

### Bug fixes

* Outlier labels no longer appear out of bounds in `tm_a_regression`.

### Miscellaneous

* Removed `teal.slice` dependencies.
Expand Down
19 changes: 7 additions & 12 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Principal component analysis module
#' `teal` module: Principal component analysis
#'
#' Module conducts principal component analysis (PCA) on a given dataset and offers different
#' ways of visualizing the outcomes, including elbow plot, circle plot, biplot, and eigenvector plot.
Expand All @@ -9,19 +9,15 @@
#' @inheritParams shared_params
#' @param dat (`data_extract_spec` or `list` of multiple `data_extract_spec`)
#' specifying columns used to compute PCA.
#' @param alpha (`numeric`, optional) Specifies point opacity.
#' - If vector of `length == 1` then the plot points will have a fixed opacity.
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @param size (`numeric`, optional) Specifies point size.
#' - If vector of `length == 1` then the plot point sizes will have a fixed size
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @param font_size (`numeric`, optional) Specifies font size.
#' It controls the font size for plot titles, axis labels, and legends.
#' - If vector of `length == 1` then the font sizes will have a fixed size.
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @templateVar ggnames "Elbow plot", "Circle plot", "Biplot", "Eigenvector plot"
#' @template ggplot2_args_multi
#'
#' @inherit shared_params return
#'
#' @examples
#' library(teal.widgets)
#'
Expand Down Expand Up @@ -306,11 +302,10 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
response[[i]]$select$multiple <- FALSE
response[[i]]$select$always_selected <- NULL
response[[i]]$select$selected <- NULL
response[[i]]$select$choices <- teal.data::col_labels(isolate(data())[[response[[i]]$dataname]])
response[[i]]$select$choices <- setdiff(
response[[i]]$select$choices,
unlist(teal.data::join_keys(isolate(data()))[[response[[i]]$dataname]])
)
all_cols <- teal.data::col_labels(isolate(data())[[response[[i]]$dataname]])
ignore_cols <- unlist(teal.data::join_keys(isolate(data()))[[response[[i]]$dataname]])
color_cols <- all_cols[!names(all_cols) %in% ignore_cols]
response[[i]]$select$choices <- choices_labeled(names(color_cols), color_cols)
}

selector_list <- teal.transform::data_extract_multiple_srv(
Expand Down
4 changes: 3 additions & 1 deletion R/tm_data_table.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Data table viewer module
#' `teal` module: Data table viewer
#'
#' Module provides a dynamic and interactive way to view `data.frame`s in a `teal` application.
#' It uses the `DT` package to display data tables in a paginated, searchable, and sortable format,
Expand Down Expand Up @@ -27,6 +27,8 @@
#' @param server_rendering (`logical`) should the data table be rendered server side
#' (see `server` argument of [DT::renderDataTable()])
#'
#' @inherit shared_params return
#'
#' @examples
#' # general data example
#' data <- teal_data()
Expand Down
19 changes: 11 additions & 8 deletions R/tm_file_viewer.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' File viewer module
#' `teal` module: File viewer
#'
#' The file viewer module provides a tool to view static files.
#' Supported formats include text formats, `PDF`, `PNG` `APNG`,
Expand All @@ -8,18 +8,20 @@
#' @inheritParams shared_params
#' @param input_path (`list`) of the input paths, optional. Each element can be:
#'
#' 1. Specific path to files of accepted formats
#' 2. A directory or a URL
#' @inherit shared_params return
#'
#' The paths can be specified as absolute paths or relative to the running
#' directory of the application.
#' Paths can be specified as absolute paths or relative to the running directory of the application.
#' Default to the current working directory if not supplied.
#'
#' @inherit shared_params return
#'
#' @examples
#' data <- teal_data()
#' data <- within(data, {
#' data <- data.frame(1)
#' })
#' datanames(data) <- c("data")
#'
#' app <- init(
#' data = teal_data(data = 1), # Mock dataset to initialize the app without error
#' data = data,
#' modules = modules(
#' tm_file_viewer(
#' input_path = list(
Expand All @@ -34,6 +36,7 @@
#' if (interactive()) {
#' shinyApp(app$ui, app$server)
#' }
#'
#' @export
#'
tm_file_viewer <- function(label = "File Viewer Module",
Expand Down
14 changes: 7 additions & 7 deletions R/tm_front_page.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Front page module
#' `teal` module: Front page
#'
#' Creates a simple front page for `teal` applications, displaying
#' introductory text, tables, additional `html` or `shiny` tags, and footnotes.
Expand All @@ -15,17 +15,17 @@
#' element, if named the name is shown first in bold, followed by the value.
#' @param show_metadata (`logical`) indicating whether the metadata of the datasets be available on the module.
#'
#' @examples
#' @inherit shared_params return
#'
#' @examples
#' data <- teal_data()
#' data <- within(data, {
#' require(nestcolor)
#' ADSL <- teal.modules.general::rADSL
#' ADSL <- rADSL
#' attr(ADSL, "metadata") <- list("Author" = "NEST team", "data_source" = "synthetic data")
#' })
#' datanames <- c("ADSL")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' datanames(data) <- "ADSL"
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' table_1 <- data.frame(Info = c("A", "B"), Text = c("A", "B"))
#' table_2 <- data.frame(`Column 1` = c("C", "D"), `Column 2` = c(5.5, 6.6), `Column 3` = c("A", "B"))
Expand All @@ -40,7 +40,7 @@
#' app <- init(
#' data = data,
#' modules = modules(
#' teal.modules.general::tm_front_page(
#' tm_front_page(
#' header_text = c(
#' "Important information" = "It can go here.",
#' "Other information" = "Can go here."
Expand Down
4 changes: 3 additions & 1 deletion R/tm_g_association.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Stack plots of variables and show association with reference variable
#' `teal` module: Stack plots of variables and show association with reference variable
#'
#' Module provides functionality for visualizing the distribution of variables and
#' their association with a reference variable.
Expand All @@ -23,6 +23,8 @@
#' @templateVar ggnames "Bivariate1", "Bivariate2"
#' @template ggplot2_args_multi
#'
#' @inherit shared_params return
#'
#' @examples
#' library(teal.widgets)
#'
Expand Down
24 changes: 7 additions & 17 deletions R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Univariate and bivariate visualizations module
#' `teal` module: Univariate and bivariate visualizations
#'
#' Module enables the creation of univariate and bivariate plots,
#' facilitating the exploration of data distributions and relationships between two variables.
Expand Down Expand Up @@ -44,10 +44,12 @@
#' Does not allow scaling to be changed by default (`FALSE`).
#' @param swap_axes (`logical`, optional) Whether to swap X and Y axes. Defaults to `FALSE`.
#'
#' @inherit shared_params return
#'
#' @examples
#' library(teal.widgets)
#'
#' # general data exapmle
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
#' require(nestcolor)
Expand Down Expand Up @@ -299,9 +301,7 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
)
}

# UI function for the bivariate module.
#' @noRd
#' @keywords internal
# UI function for the bivariate module
ui_g_bivariate <- function(id, ...) {
args <- list(...)
is_single_dataset_value <- teal.transform::is_single_dataset(
Expand Down Expand Up @@ -442,9 +442,7 @@ ui_g_bivariate <- function(id, ...) {
)
}

# Server function for the bivariate module.
#' @noRd
#' @keywords internal
# Server function for the bivariate module
srv_g_bivariate <- function(id,
data,
reporter,
Expand Down Expand Up @@ -726,8 +724,6 @@ srv_g_bivariate <- function(id,
}

# Get Substituted ggplot call
#' @noRd
#' @keywords internal
bivariate_plot_call <- function(data_name,
x = character(0),
y = character(0),
Expand Down Expand Up @@ -778,8 +774,6 @@ bivariate_plot_call <- function(data_name,

# Create ggplot part of plot call
# Due to the type of the x and y variable the plot type is chosen
#' @noRd
#' @keywords internal
bivariate_ggplot_call <- function(x_class = c("NULL", "numeric", "integer", "factor", "character", "logical"),
y_class = c("NULL", "numeric", "integer", "factor", "character", "logical"),
freq = TRUE,
Expand Down Expand Up @@ -963,9 +957,7 @@ bivariate_ggplot_call <- function(x_class = c("NULL", "numeric", "integer", "fac
plot_call
}

#' Create facet call
#' @noRd
#' @keywords internal
# Create facet call
facet_ggplot_call <- function(row_facet = character(0),
col_facet = character(0),
free_x_scales = FALSE,
Expand Down Expand Up @@ -996,8 +988,6 @@ facet_ggplot_call <- function(row_facet = character(0),
}
}

#' @noRd
#' @keywords internal
coloring_ggplot_call <- function(colour,
fill,
size,
Expand Down
4 changes: 3 additions & 1 deletion R/tm_g_distribution.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Distribution analysis module
#' `teal` module: Distribution analysis
#'
#' Module is designed to explore the distribution of a single variable within a given dataset.
#' It offers several tools, such as histograms, Q-Q plots, and various statistical tests to
Expand All @@ -25,6 +25,8 @@
#' @templateVar ggnames "Histogram", "QQplot"
#' @template ggplot2_args_multi
#'
#' @inherit shared_params return
#'
#' @examples
#' library(teal.widgets)
#'
Expand Down
4 changes: 1 addition & 3 deletions R/tm_g_response.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Response plot module
#' `teal` module: Response plot
#'
#' Generates a response plot for a given `response` and `x` variables.
#' This module allows users customize and add annotations to the plot depending
Expand Down Expand Up @@ -422,7 +422,6 @@ srv_g_response <- function(id,
env = list(resp_var = resp_var)
)
) %>%
# nolint start
# rowf and colf will be a NULL if not set by a user
teal.code::eval_code(
substitute(
Expand All @@ -442,7 +441,6 @@ srv_g_response <- function(id,
env = list(x_cl = x_cl, rowf = rowf, colf = colf)
)
)
# nolint end

plot_call <- substitute(
expr = ggplot(ANL2, aes(x = x_cl, y = ns)) +
Expand Down
10 changes: 3 additions & 7 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Scatterplot module
#' `teal` module: Scatterplot
#'
#' Generates a customizable scatterplot using `ggplot2`.
#' This module allows users to select variables for the x and y axes,
Expand All @@ -22,18 +22,14 @@
#' Specifies the variable(s) for faceting rows.
#' @param col_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`, optional)
#' Specifies the variable(s) for faceting columns.
#' @param alpha (`numeric`, optional) Specifies point opacity.
#' - If vector of `length == 1` then the plot points will have a fixed opacity.
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @param size (`numeric`, optional) Specifies point size.
#' - If vector of `length == 1` then the plot point sizes will have a fixed size
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @param shape (`character`, optional) A character vector with the names of the
#' shape, e.g. `c("triangle", "square", "circle")`. It defaults to `shape_names`. This is a complete list from
#' `vignette("ggplot2-specs", package="ggplot2")`.
#' @param max_deg (`integer`, optional) The maximum degree for the polynomial trend line. Must not be less than 1.
#' @param table_dec (`integer`, optional) Number of decimal places used to round numeric values in the table.
#'
#' @inherit shared_params return
#'
#' @examples
#' library(teal.widgets)
#'
Expand Down
6 changes: 5 additions & 1 deletion R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Scatterplot matrix module
#' `teal` module: Scatterplot matrix
#'
#' Generates a scatterplot matrix from selected `variables` from datasets.
#' Each plot within the matrix represents the relationship between two variables,
Expand All @@ -16,6 +16,8 @@
#' `data_extract_spec` use `select_spec(..., ordered = TRUE)` if plot elements should be
#' rendered according to selection order.
#'
#' @inherit shared_params return
#'
#' @examples
#' # general data example
#' data <- teal_data()
Expand Down Expand Up @@ -489,6 +491,7 @@ srv_g_scatterplotmatrix <- function(id, data, reporter, filter_panel_api, variab
#' stats::cor.test(x, y, na.action = "na.fail")
#' stats::cor.test(~ x + y, na.action = "na.fail")
#' ```
#'
#' @param x,y (`numeric`) vectors of data values. `x` and `y` must have the same length.
#' @param .f (`function`) function that accepts x and y as formula input `~ x + y`.
#' Default `stats::cor.test`.
Expand All @@ -497,6 +500,7 @@ srv_g_scatterplotmatrix <- function(id, data, reporter, filter_panel_api, variab
#' @param round_pval (`integer(1)`) optional. Number of decimal places to use when rounding the p-value.
#'
#' @return Character with stats. For [stats::cor.test()] correlation coefficient and p-value.
#'
#' @examples
#' set.seed(1)
#' x <- runif(25, 0, 1)
Expand Down
Loading

0 comments on commit f164561

Please sign in to comment.