From ca0e36f30788086a2f094d728aa8c13423fcf267 Mon Sep 17 00:00:00 2001 From: DivadNojnarg Date: Fri, 5 Jul 2024 16:13:10 +0200 Subject: [PATCH] update for blockr 0.0.2 --- DESCRIPTION | 2 +- NAMESPACE | 8 -------- NEWS.md | 12 ++++++++++++ R/admiral-dpc-block.R | 14 ++------------ R/code.R | 20 ++------------------ R/filter-expr-block.R | 12 +----------- R/summarize-expr-block.R | 21 +++++---------------- R/utils.R | 10 +++++----- README.Rmd | 26 +++++++++++++------------- inst/examples/bms-demo-cdisc/app.R | 30 ++++++++++++++++++++---------- inst/examples/code-block/app.R | 4 ++-- man/admiral_dpc_block.Rd | 16 ---------------- man/code_block.Rd | 14 ++++---------- man/code_field.Rd | 2 -- man/filter_expr_block.Rd | 16 ---------------- man/summarize_expr_block.Rd | 16 ---------------- 16 files changed, 67 insertions(+), 156 deletions(-) create mode 100644 NEWS.md delete mode 100644 man/admiral_dpc_block.Rd delete mode 100644 man/filter_expr_block.Rd delete mode 100644 man/summarize_expr_block.Rd diff --git a/DESCRIPTION b/DESCRIPTION index a87be97..c594ab7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: blockr.extra Title: Experimental Blocks for blockr -Version: 0.0.1.9000 +Version: 0.0.2.9000 Authors@R: c(person(given = "Christoph", family = "Sax", diff --git a/NAMESPACE b/NAMESPACE index b94b5c5..3dcedd0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,22 +4,14 @@ S3method(layout,code_plot_block) S3method(layout,code_transform_block) S3method(ui_fields,admiral_dpc_block) S3method(ui_fields,filter_expr_block) -S3method(ui_fields,summarize_expr_block) S3method(ui_input,code_field) S3method(ui_update,code_field) S3method(validate_field,code_field) -export(admiral_dpc_block) -export(code_field) -export(code_plot_block) -export(code_transform_block) -export(filter_expr_block) export(new_code_field) export(new_code_plot_block) export(new_code_transform_block) -export(summarize_expr_block) import(blockr) importFrom(admiral,derive_param_computed) -importFrom(dplyr,filter) importFrom(rlang,exprs) importFrom(shiny,div) importFrom(shiny,p) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..3acc168 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,12 @@ +# blockr.extra 0.0.2.9000 + +## Documentation +- Updated readme example with new API. + +## Breaking changes +- Change blocks constructor names to `new_*_block` according to `{blockr}` 0.0.2. +- Remove `data` parameter from constructor functions. + +# blockr.extra (development version) + +* Initial GitHub version. diff --git a/R/admiral-dpc-block.R b/R/admiral-dpc-block.R index 65d9162..7c1b533 100644 --- a/R/admiral-dpc-block.R +++ b/R/admiral-dpc-block.R @@ -11,14 +11,13 @@ # ) # # pkgload::load_all("."); -# stack <- new_stack(data_block, mutate_block, admiral_dpc_block); +# stack <- new_stack(new_dataset_block, new_mutate_block, new_admiral_dpc_block); # serve_stack(stack) #' @importFrom admiral derive_param_computed #' @importFrom rlang exprs #' @import blockr -new_admiral_dpc_block <- function(data, - by_vars = NULL, +new_admiral_dpc_block <- function(by_vars = NULL, parameters = NULL, set_values_to = NULL, ...) { @@ -123,15 +122,6 @@ new_admiral_dpc_block <- function(data, ) } -#' Admiral Block -#' -#' @inheritParams blockr::new_block -#' -#' @export -admiral_dpc_block <- function(data, ...) { - initialize_block(new_admiral_dpc_block(data, ...), data) -} - #' @export ui_fields.admiral_dpc_block <- function(x, ns, inputs_hidden, ...) { ui_fields_one_column(x = x, ns = ns, inputs_hidden = inputs_hidden) diff --git a/R/code.R b/R/code.R index 7d67a44..732718d 100644 --- a/R/code.R +++ b/R/code.R @@ -11,10 +11,6 @@ new_code_field <- function(value = character(), ...) { ) } -#' @rdname code_field -#' @export -code_field <- function(...) validate_field(new_code_field(...)) - #' @rdname code_field #' @export validate_field.code_field <- function(x) { @@ -43,7 +39,7 @@ ui_update.code_field <- function(x, session, id, name) { #' @param ... Ignored. #' @name code_block #' @export -new_code_transform_block <- function(data, ...) { +new_code_transform_block <- function(...) { new_block( fields = list( code = new_code_field("data # from parent block") @@ -60,13 +56,7 @@ new_code_transform_block <- function(data, ...) { #' @rdname code_block #' @export -code_transform_block <- function(data, ...) { - initialize_block(new_code_transform_block(data, ...), data) -} - -#' @rdname code_block -#' @export -new_code_plot_block <- function(data, ...) { +new_code_plot_block <- function(...) { new_block( fields = list( code = new_code_field("plot(data) # from parent block") @@ -81,12 +71,6 @@ new_code_plot_block <- function(data, ...) { ) } -#' @rdname code_block -#' @export -code_plot_block <- function(data, ...) { - initialize_block(new_code_plot_block(data, ...), data) -} - code_layout_fields <- function(x, fields, ...) { # we apply padding because there seems to be some # CSS that pushes the editor up and hides the buttons diff --git a/R/filter-expr-block.R b/R/filter-expr-block.R index d73f552..c2e8bea 100644 --- a/R/filter-expr-block.R +++ b/R/filter-expr-block.R @@ -21,7 +21,7 @@ filter_expr_expression <- function(value = c(a = "2.1", b = "4.5")) { ) } -new_filter_expr_block <- function(data, value = NULL, ...) { +new_filter_expr_block <- function(value = NULL, ...) { fields <- list( value = new_keyvalue_field( value = value, @@ -45,16 +45,6 @@ new_filter_expr_block <- function(data, value = NULL, ...) { ) } -#' Filter Expression Block -#' -#' @inheritParams blockr::new_block -#' -#' @export -#' @importFrom dplyr filter -filter_expr_block <- function(data, ...) { - initialize_block(new_filter_expr_block(data, ...), data) -} - #' @export ui_fields.filter_expr_block <- function(x, ns, inputs_hidden, ...) { ui_fields_one_column(x = x, ns = ns, inputs_hidden = inputs_hidden) diff --git a/R/summarize-expr-block.R b/R/summarize-expr-block.R index 08ae5e5..10e9065 100644 --- a/R/summarize-expr-block.R +++ b/R/summarize-expr-block.R @@ -1,12 +1,11 @@ # pkgload::load_all("."); -# stack <- new_stack(data_block, summarize_expr_block); +# stack <- new_stack(new_dataset_block, new_summarize_expr_block); # serve_stack(stack) #' @importFrom admiral derive_param_computed #' @importFrom rlang exprs #' @import blockr -new_summarize_expr_block <- function(data, - new_cols = NULL, +new_summarize_expr_block <- function(new_cols = NULL, group_by = NULL, ...) { @@ -93,17 +92,7 @@ new_summarize_expr_block <- function(data, ) } -#' Summarize By Block -#' -#' @inheritParams blockr::new_block -#' #' @export -summarize_expr_block <- function(data, ...) { - initialize_block(new_summarize_expr_block(data, ...), data) -} - - -#' @export -ui_fields.summarize_expr_block <- function(x, ns, inputs_hidden, ...) { - ui_fields_one_column(x = x, ns = ns, inputs_hidden = inputs_hidden) -} +#ui_fields.summarize_expr_block <- function(x, ns, inputs_hidden, ...) { +# ui_fields_one_column(x = x, ns = ns, inputs_hidden = inputs_hidden) +#} diff --git a/R/utils.R b/R/utils.R index 00b5048..3741733 100644 --- a/R/utils.R +++ b/R/utils.R @@ -40,11 +40,11 @@ register_blockr_extra_blocks <- function(pkg) { register_blocks( constructor = c( - admiral_dpc_block, - filter_expr_block, - summarize_expr_block, - code_transform_block, - code_plot_block + new_admiral_dpc_block, + new_filter_expr_block, + new_summarize_expr_block, + new_code_transform_block, + new_code_plot_block ), name = c( "admiral dpc block", diff --git a/README.Rmd b/README.Rmd index 0b61b3f..7c77ddb 100644 --- a/README.Rmd +++ b/README.Rmd @@ -28,11 +28,11 @@ library(bslib) Provides the following blocks: -- `filter_expr_block` -- `summarize_expr_block` -- `admiral_dpc_block` -- `code_plot_block` -- `code_transform_block` +- `new_filter_expr_block` +- `new_summarize_expr_block` +- `new_admiral_dpc_block` +- `new_code_plot_block` +- `new_code_transform_block` ## Usage @@ -43,17 +43,17 @@ library(blockr.extra) options(BLOCKR_DEV = TRUE) pkgload::load_all(".") -stack <- new_stack( - data_block, - filter_expr_block, - summarize_expr_block -); -serve_stack(stack) +stack1 <- new_stack( + new_dataset_block, + new_filter_expr_block, + new_summarize_expr_block +) # see admiral vingette for how to use admiral_dpc_block -stack <- new_stack(data_block, mutate_block, admiral_dpc_block) -serve_stack(stack) +stack2 <- new_stack(new_dataset_block, new_mutate_block, new_admiral_dpc_block) +set_workspace(summarize_expr_stack = stack1, admiral_stack = stack2) +serve_workspace(clear = FALSE) ``` ## Installation diff --git a/inst/examples/bms-demo-cdisc/app.R b/inst/examples/bms-demo-cdisc/app.R index 9656c6b..b95cd6e 100644 --- a/inst/examples/bms-demo-cdisc/app.R +++ b/inst/examples/bms-demo-cdisc/app.R @@ -7,17 +7,27 @@ library(ggiraph) # Note: sometimes memories issue due to the join block # can be solved by restarting R between each run. serve_workspace( - stack1 = new_stack(lab_data_block, head_block), - stack2 = new_stack(demo_data_block, demo_join_block), + stack1 = new_stack(new_dataset_block("lab", package = "blockr.data"), new_head_block), + stack2 = new_stack(new_dataset_block("demo", package = "blockr.data"), new_join_block( + y = "demo", + type = "inner", + by_col = c("STUDYID", "USUBJID") + )), stack3 = new_stack( - result_block, - demo_filter_block_1, - demo_filter_block_2#, - #demo_arrange_block, - #asfactor_block#, - #demo_group_by_block, - #demo_summarize_block, - #ggiraph_block + new_result_block, + new_filter_block( + columns = "LBTEST", + values = "Hemoglobin" + ), + new_filter_block( + columns = "VISIT", + values = "UNSCHEDULED", + filter_fun = "!startsWith" + ), + new_arrange_block(columns = "VISITNUM"), + #new_asfactor_block, + new_group_by_block(columns = c("VISIT", "ACTARM"))#, + #new_summarize_block(func = c(), default_columns = c("LBSTRESN", "LBSTRESN")) ), title = "My workspace" ) diff --git a/inst/examples/code-block/app.R b/inst/examples/code-block/app.R index 2ec527f..1f099c7 100644 --- a/inst/examples/code-block/app.R +++ b/inst/examples/code-block/app.R @@ -2,8 +2,8 @@ devtools::load_all() library(shiny) stack <- new_stack( - data_block, - code_transform_block + new_dataset_block, + new_code_transform_block ) ui <- fluidPage( diff --git a/man/admiral_dpc_block.Rd b/man/admiral_dpc_block.Rd deleted file mode 100644 index 4c8ca49..0000000 --- a/man/admiral_dpc_block.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/admiral-dpc-block.R -\name{admiral_dpc_block} -\alias{admiral_dpc_block} -\title{Admiral Block} -\usage{ -admiral_dpc_block(data, ...) -} -\arguments{ -\item{data}{Block input data} - -\item{...}{Further (metadata) attributes} -} -\description{ -Admiral Block -} diff --git a/man/code_block.Rd b/man/code_block.Rd index f5a0211..74978ed 100644 --- a/man/code_block.Rd +++ b/man/code_block.Rd @@ -3,23 +3,17 @@ \name{code_block} \alias{code_block} \alias{new_code_transform_block} -\alias{code_transform_block} \alias{new_code_plot_block} -\alias{code_plot_block} \title{Code Block} \usage{ -new_code_transform_block(data, ...) +new_code_transform_block(...) -code_transform_block(data, ...) - -new_code_plot_block(data, ...) - -code_plot_block(data, ...) +new_code_plot_block(...) } \arguments{ -\item{data}{Dataset.} - \item{...}{Ignored.} + +\item{data}{Dataset.} } \description{ Code Block diff --git a/man/code_field.Rd b/man/code_field.Rd index 21a644a..39fc5a4 100644 --- a/man/code_field.Rd +++ b/man/code_field.Rd @@ -8,8 +8,6 @@ \usage{ new_code_field(value = character(), ...) -code_field(...) - \method{validate_field}{code_field}(x) } \arguments{ diff --git a/man/filter_expr_block.Rd b/man/filter_expr_block.Rd deleted file mode 100644 index 3be999e..0000000 --- a/man/filter_expr_block.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/filter-expr-block.R -\name{filter_expr_block} -\alias{filter_expr_block} -\title{Filter Expression Block} -\usage{ -filter_expr_block(data, ...) -} -\arguments{ -\item{data}{Block input data} - -\item{...}{Further (metadata) attributes} -} -\description{ -Filter Expression Block -} diff --git a/man/summarize_expr_block.Rd b/man/summarize_expr_block.Rd deleted file mode 100644 index fa1a766..0000000 --- a/man/summarize_expr_block.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/summarize-expr-block.R -\name{summarize_expr_block} -\alias{summarize_expr_block} -\title{Summarize By Block} -\usage{ -summarize_expr_block(data, ...) -} -\arguments{ -\item{data}{Block input data} - -\item{...}{Further (metadata) attributes} -} -\description{ -Summarize By Block -}