Skip to content

Commit

Permalink
Pre-release activities (#1021)
Browse files Browse the repository at this point in the history
part of insightsengineering/nestdevs-tasks#48

- [x] Review and update:
      - README.md (check example code)
      - NEWS.md
- [x] Run urlchecker::url_check() to identify broken links and fix
- [x] Review functions:
       - @example tag, make sure it runs, fix if otherwise
- Make sure functions has @return tag to document the return value
       - no \dontrun tag, replace with if(interactive()) if needed
- [x] Sanity check of all vignettes, make sure there is no typo, no
wrong format, etc.
- [x] Run R CMD check --as-cran make sure everything pass
- [x] Package Title is not duplicated in Package Description in
DESCRIPTION file (e.g. this happens in teal.slice currently)
- [x] All package names in Title and Description fields of DESCRIPTION
file are quoted with '
- [x] You have checked the Package Release Template
https://github.com/insightsengineering/teal.reporter/pull/205/files
- [x] Make sure there are no ::: in examples
- [x] Make sure all teal.* mentions are lower-cased and quoted
- [x] Make Sure inst/WORDLIST is minimalized
- [x] Make sure non-exported functions do not have examples
- [x] Make sure each link to our documentation hosted with pkgdown on
github pages do not have /main/ in the address but it has /latest/
instead, so we always expose the documentation of the latest release and
not what's currently on main branch but not yet released
- [x] remove old rd syntax
- [x] switch from title case into sentence case for title and
descriotion of functions.

---------

Signed-off-by: kartikeya kirar <[email protected]>
Signed-off-by: Aleksander Chlebowski <[email protected]>
Signed-off-by: Vedha Viyash <[email protected]>
Signed-off-by: Marcin <[email protected]>
Signed-off-by: André Veríssimo <[email protected]>
Co-authored-by: Dawid Kałędkowski <[email protected]>
Co-authored-by: Aleksander Chlebowski <[email protected]>
Co-authored-by: go_gonzo <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aleksander Chlebowski <[email protected]>
Co-authored-by: André Veríssimo <[email protected]>
Co-authored-by: Chendi Liao <[email protected]>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Dony Unardi <[email protected]>
Co-authored-by: vedhav <[email protected]>
Co-authored-by: Vedha Viyash <[email protected]>
Co-authored-by: Marcin <[email protected]>
  • Loading branch information
13 people authored Feb 6, 2024
1 parent db0a420 commit 053b650
Show file tree
Hide file tree
Showing 143 changed files with 2,559 additions and 2,170 deletions.
3 changes: 1 addition & 2 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL,
indentation_linter = NULL
object_usage_linter = NULL
)
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ Collate:
'module_tabs_with_filters.R'
'module_teal.R'
'module_teal_with_splash.R'
'modules_debugging.R'
'reporter_previewer_module.R'
'show_rcode_modal.R'
'tdata.R'
Expand Down
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2: do not edit by hand

S3method(c,teal_slices)
S3method(format,teal_module)
S3method(format,teal_modules)
S3method(get_metadata,default)
S3method(get_metadata,tdata)
S3method(join_keys,tdata)
Expand All @@ -9,8 +11,6 @@ S3method(print,teal_modules)
S3method(srv_nested_tabs,default)
S3method(srv_nested_tabs,teal_module)
S3method(srv_nested_tabs,teal_modules)
S3method(toString,teal_module)
S3method(toString,teal_modules)
S3method(ui_nested_tabs,default)
S3method(ui_nested_tabs,teal_module)
S3method(ui_nested_tabs,teal_modules)
Expand Down
49 changes: 25 additions & 24 deletions NEWS.md

Large diffs are not rendered by default.

110 changes: 5 additions & 105 deletions R/dummy_functions.R
Original file line number Diff line number Diff line change
@@ -1,81 +1,9 @@
#' Get dummy `CDISC` data
#'
#' Get dummy `CDISC` data including `ADSL`, `ADAE` and `ADLB`.
#' Some NAs are also introduced to stress test.
#'
#' @return `cdisc_data`
#' @keywords internal
example_cdisc_data <- function() { # nolint
ADSL <- data.frame( # nolint
STUDYID = "study",
USUBJID = 1:10,
SEX = sample(c("F", "M"), 10, replace = TRUE),
AGE = stats::rpois(10, 40)
)
ADTTE <- rbind(ADSL, ADSL, ADSL) # nolint
ADTTE$PARAMCD <- rep(c("OS", "EFS", "PFS"), each = 10) # nolint
ADTTE$AVAL <- c( # nolint
stats::rnorm(10, mean = 700, sd = 200), # dummy OS level
stats::rnorm(10, mean = 400, sd = 100), # dummy EFS level
stats::rnorm(10, mean = 450, sd = 200) # dummy PFS level
)

ADSL$logical_test <- sample(c(TRUE, FALSE, NA), size = nrow(ADSL), replace = TRUE) # nolint
ADSL$SEX[c(2, 5)] <- NA # nolint

res <- teal.data::cdisc_data(
ADSL = ADSL,
ADTTE = ADTTE,
code = '
ADSL <- data.frame(
STUDYID = "study",
USUBJID = 1:10,
SEX = sample(c("F", "M"), 10, replace = TRUE),
AGE = rpois(10, 40)
)
ADTTE <- rbind(ADSL, ADSL, ADSL)
ADTTE$PARAMCD <- rep(c("OS", "EFS", "PFS"), each = 10)
ADTTE$AVAL <- c(
rnorm(10, mean = 700, sd = 200),
rnorm(10, mean = 400, sd = 100),
rnorm(10, mean = 450, sd = 200)
)
ADSL$logical_test <- sample(c(TRUE, FALSE, NA), size = nrow(ADSL), replace = TRUE)
ADSL$SEX[c(2, 5)] <- NA
'
)
return(res)
}

#' Get datasets to go with example modules.
#'
#' Creates a nested list, the structure of which matches the module hierarchy created by `example_modules`.
#' Each list leaf is the same `FilteredData` object.
#'
#' @return named list of `FilteredData` objects, each with `ADSL` set.
#' @keywords internal
example_datasets <- function() { # nolint
dummy_cdisc_data <- example_cdisc_data()
datasets <- teal_data_to_filtered_data(dummy_cdisc_data)
list(
"d2" = list(
"d3" = list(
"aaa1" = datasets,
"aaa2" = datasets,
"aaa3" = datasets
),
"bbb" = datasets
),
"ccc" = datasets
)
}

#' An example `teal` module
#'
#' @description `r lifecycle::badge("experimental")`
#' @inheritParams module
#' @return A `teal` module which can be included in the `modules` argument to [teal::init()].
#' `r lifecycle::badge("experimental")`
#'
#' @inheritParams teal_modules
#' @return A `teal` module which can be included in the `modules` argument to [init()].
#' @examples
#' app <- init(
#' data = teal_data(IRIS = iris, MTCARS = mtcars),
Expand All @@ -92,7 +20,6 @@ example_module <- function(label = "example teal module", datanames = "all") {
server = function(id, data) {
checkmate::assert_class(data(), "teal_data")
moduleServer(id, function(input, output, session) {
ns <- session$ns
updateSelectInput(session, "dataname", choices = isolate(teal.data::datanames(data())))
output$text <- renderPrint({
req(input$dataname)
Expand All @@ -101,7 +28,7 @@ example_module <- function(label = "example teal module", datanames = "all") {
teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(data())),
title = "Association Plot"
title = "Example Code"
)
})
},
Expand All @@ -118,30 +45,3 @@ example_module <- function(label = "example teal module", datanames = "all") {
datanames = datanames
)
}


#' Get example modules.
#'
#' Creates an example hierarchy of `teal_modules` from which a `teal` app can be created.
#' @param datanames (`character`)\cr
#' names of the datasets to be used in the example modules. Possible choices are `ADSL`, `ADTTE`.
#' @return `teal_modules`
#' @keywords internal
example_modules <- function(datanames = c("ADSL", "ADTTE")) {
checkmate::assert_subset(datanames, c("ADSL", "ADTTE"))
mods <- modules(
label = "d1",
modules(
label = "d2",
modules(
label = "d3",
example_module(label = "aaa1", datanames = datanames),
example_module(label = "aaa2", datanames = datanames),
example_module(label = "aaa3", datanames = datanames)
),
example_module(label = "bbb", datanames = datanames)
),
example_module(label = "ccc", datanames = datanames)
)
return(mods)
}
19 changes: 9 additions & 10 deletions R/get_rcode_utils.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Generates library calls from current session info
#'
#' Function to create multiple library calls out of current session info to make reproducible code works.
#' Function to create multiple library calls out of current session info to ensure reproducible code works.
#'
#' @return Character object contain code
#' @return Character vector of `library(<package>)` calls.
#' @keywords internal
get_rcode_libraries <- function() {
vapply(
Expand All @@ -18,21 +18,20 @@ get_rcode_libraries <- function() {
paste0(collapse = "")
}



#' @noRd
#' @keywords internal
get_rcode_str_install <- function() {
code_string <- getOption("teal.load_nest_code")

if (!is.null(code_string) && is.character(code_string)) {
return(code_string)
if (is.character(code_string)) {
code_string
} else {
"# Add any code to install/load your NEST environment here\n"
}

return("# Add any code to install/load your NEST environment here\n")
}

#' Get datasets code
#'
#' Get combined code from `FilteredData` and from `CodeClass` object.
#' Retrieve complete code to create, verify, and filter a dataset.
#'
#' @param datanames (`character`) names of datasets to extract code from
#' @param datasets (`FilteredData`) object
Expand Down
37 changes: 21 additions & 16 deletions R/include_css_js.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
#'
#' `system.file` should not be used to access files in other packages, it does
#' not work with `devtools`. Therefore, we redefine this method in each package
#' as needed. Thus, we do not export this method
#' as needed. Thus, we do not export this method.
#'
#' @param pattern (`character`) pattern of files to be included
#'
#' @return HTML code that includes `CSS` files
#' @return HTML code that includes `CSS` files.
#' @keywords internal
include_css_files <- function(pattern = "*") {
css_files <- list.files(
system.file("css", package = "teal", mustWork = TRUE),
pattern = pattern, full.names = TRUE
)
return(
shiny::singleton(
shiny::tags$head(lapply(css_files, shiny::includeCSS))
)

singleton(
tags$head(lapply(css_files, includeCSS))
)
}

Expand All @@ -29,14 +28,14 @@ include_css_files <- function(pattern = "*") {
#' @param pattern (`character`) pattern of files to be included, passed to `system.file`
#' @param except (`character`) vector of basename filenames to be excluded
#'
#' @return HTML code that includes `JS` files
#' @return HTML code that includes `JS` files.
#' @keywords internal
include_js_files <- function(pattern = NULL, except = NULL) {
checkmate::assert_character(except, min.len = 1, any.missing = FALSE, null.ok = TRUE)
js_files <- list.files(system.file("js", package = "teal", mustWork = TRUE), pattern = pattern, full.names = TRUE)
js_files <- js_files[!(basename(js_files) %in% except)] # no-op if except is NULL

return(singleton(lapply(js_files, includeScript)))
singleton(lapply(js_files, includeScript))
}

#' Run `JS` file from `/inst/js/` package directory
Expand All @@ -48,32 +47,38 @@ include_js_files <- function(pattern = NULL, except = NULL) {
#'
#' `system.file` should not be used to access files in other packages, it does
#' not work with `devtools`. Therefore, we redefine this method in each package
#' as needed. Thus, we do not export this method
#' as needed. Thus, we do not export this method.
#'
#' @param files (`character`) vector of filenames
#' @param files (`character`) vector of filenames.
#'
#' @return returns `NULL`, invisibly.
#' @keywords internal
run_js_files <- function(files) {
checkmate::assert_character(files, min.len = 1, any.missing = FALSE)
lapply(files, function(file) {
shinyjs::runjs(paste0(readLines(system.file("js", file, package = "teal", mustWork = TRUE)), collapse = "\n"))
})
return(invisible(NULL))
invisible(NULL)
}

#' Code to include teal `CSS` and `JavaScript` files
#' Code to include `teal` `CSS` and `JavaScript` files
#'
#' This is useful when you want to use the same `JavaScript` and `CSS` files that are
#' used with the teal application.
#' This is also useful for running standalone modules in teal with the correct
#' used with the `teal` application.
#' This is also useful for running standalone modules in `teal` with the correct
#' styles.
#' Also initializes `shinyjs` so you can use it.
#'
#' @return HTML code to include
#' Simply add `include_teal_css_js()` as one of the UI elements.
#' @return A `shiny.tag.list`.
#' @examples
#' # use non-exported function from teal
#' include_teal_css_js <- getFromNamespace("include_teal_css_js", "teal")
#' shiny_ui <- tagList(
#' teal:::include_teal_css_js(),
#' include_teal_css_js(),
#' p("Hello")
#' )
#'
#' @keywords internal
include_teal_css_js <- function() {
tagList(
Expand Down
Loading

0 comments on commit 053b650

Please sign in to comment.