Skip to content

Commit

Permalink
Merge branch '904_tdata_in_modules@refactor' of github.com:insightsen…
Browse files Browse the repository at this point in the history
…gineering/teal into 904_tdata_in_modules@refactor
  • Loading branch information
Aleksander Chlebowski committed Nov 20, 2023
2 parents b0844c1 + b7b6b3a commit c5cd680
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
14 changes: 12 additions & 2 deletions R/dummy_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ example_datasets <- function() { # nolint
#' @examples
#' app <- init(
#' data = teal_data(
#' dataset("IRIS", iris),
#' dataset("MTCARS", mtcars)
#' IRIS = iris,
#' MTCARS = mtcars
#' ),
#' modules = example_module()
#' )
Expand All @@ -92,6 +92,16 @@ example_module <- function(label = "example teal module", datanames = "all") {
checkmate::assert_string(label)
module(
label,
ui = function(id) {
ns <- NS(id)
teal.widgets::standard_layout(
output = dataTableOutput(ns("table")),
encoding = div(
selectInput(ns("dataname"), "Choose a dataset", choices = NULL),
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
)
)
},
server = function(id, data) {
data_downgraded <- reactive(.tdata_downgrade(data))
checkmate::assert_class(data_downgraded(), "tdata")
Expand Down
9 changes: 3 additions & 6 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@
#' @include modules.R
#'
#' @examples
#' new_iris <- transform(iris, id = seq_len(nrow(iris)))
#' new_mtcars <- transform(mtcars, id = seq_len(nrow(mtcars)))
#'
#' app <- init(
#' data = teal_data(
#' dataset("new_iris", new_iris),
#' dataset("new_mtcars", new_mtcars),
#' new_iris = transform(iris, id = seq_len(nrow(iris))),
#' new_mtcars = transform(mtcars, id = seq_len(nrow(mtcars))),
#' code = "
#' new_iris <- transform(iris, id = seq_len(nrow(iris)))
#' new_mtcars <- transform(mtcars, id = seq_len(nrow(mtcars)))
Expand All @@ -78,7 +75,7 @@
#' "Iris Sepal.Length histogram",
#' server = function(input, output, session, data) {
#' output$hist <- renderPlot(
#' hist(data[["new_iris"]]()$Sepal.Length)
#' hist(data()[["new_iris"]]$Sepal.Length)
#' )
#' },
#' ui = function(id, ...) {
Expand Down
4 changes: 2 additions & 2 deletions R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' library(shiny)
#'
#' app <- init(
#' data = teal_data(dataset("iris", iris)),
#' data = teal_data(iris = iris),
#' modules = modules(
#' label = "Modules",
#' modules(
Expand Down Expand Up @@ -199,7 +199,7 @@ is_arg_used <- function(modules, arg) {
#' library(shiny)
#'
#' app <- init(
#' data = teal_data(dataset("iris", iris)),
#' data = teal_data(iris = iris),
#' modules = list(
#' module(
#' label = "Module",
Expand Down
4 changes: 2 additions & 2 deletions man/example_module.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions man/init.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/module.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/modules.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c5cd680

Please sign in to comment.