From 59e9938c885b53a3ae8f9d842a1c00a42d534fac Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Thu, 19 Sep 2024 00:12:39 +0200 Subject: [PATCH 1/4] Add cran-comments --- .Rbuildignore | 1 + cran-comments.md | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index 0704879..be1f0a5 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,4 @@ _NAMESPACE ^\.github$ images/ ^vignettes/articles$ +^cran-comments\.md$ diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. From df2f1371d5ee7fd52b3a4aa2f2e2bb40384eb580 Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Thu, 19 Sep 2024 00:37:35 +0200 Subject: [PATCH 2/4] Add Tabulator JS author --- DESCRIPTION | 6 ++++-- README.Rmd | 2 +- README.md | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 80e7633..c4268ae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,8 +4,10 @@ Title: R Bindings for Tabulator JS Version: 0.1.2 Date: 2024-09-18 Authors@R: c( - person("Stefan", "Kuethe", email = "crazycapivara@gmail.com", role = c("aut", "cre")), - person("Nico", "Friess", email = "nico.friess@eoda.de", role = c("aut")) + person("Stefan", "Kuethe", email = "crazycapivara@gmail.com", role = c("aut", "cre", "cph")), + person("Nico", "Friess", email = "nico.friess@eoda.de", role = "aut"), + person("Oli", "Folkerd", role = "cph", + comment = "Author of included tabulator.js library") ) Maintainer: Stefan Kuethe Description: Provides R bindings for 'Tabulator JS' . diff --git a/README.Rmd b/README.Rmd index 19f6ef3..ac7a8f4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -46,7 +46,7 @@ Bindings for Python are available at [https://github.com/eodaGmbH/py-tabulator]( ## Installation -Once on CRAN you can install rtabulator with: +You can install the released version of rtabulator from [CRAN](https://CRAN.R-project.org) with: ``` r install.packages("rtabulator") diff --git a/README.md b/README.md index 95bec62..230530d 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ Bindings for Python are available at ## Installation -Once on CRAN you can install rtabulator with: +You can install the released version of rtabulator from +[CRAN](https://CRAN.R-project.org) with: ``` r install.packages("rtabulator") From f318900b5e708c46b95e7197fec194372528d6ef Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Thu, 19 Sep 2024 00:42:06 +0200 Subject: [PATCH 3/4] Add example --- R/tabulator_options.R | 1 + man/set_options_group_by.Rd | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/R/tabulator_options.R b/R/tabulator_options.R index 264535f..4f76e7b 100644 --- a/R/tabulator_options.R +++ b/R/tabulator_options.R @@ -132,6 +132,7 @@ set_options_pagination <- function( #' @inheritParams set_formatter_html #' @inheritParams tabulator_options #' @returns tabulator htmlwidget +#' @example examples/options/group_by_options.R #' @export set_options_group_by <- function( widget, diff --git a/man/set_options_group_by.Rd b/man/set_options_group_by.Rd index 1b16175..e31fac4 100644 --- a/man/set_options_group_by.Rd +++ b/man/set_options_group_by.Rd @@ -32,3 +32,7 @@ tabulator htmlwidget \description{ Set group by options } +\examples{ +tabulator(iris) |> + set_options_group_by("Species", group_start_open = FALSE) +} From abdd3a1040262a8dcca673b37b51584b73162c8d Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Thu, 19 Sep 2024 01:01:04 +0200 Subject: [PATCH 4/4] Add examples --- R/context_calls.R | 45 ++++++++++++++++++++++++++++++++--- R/tabulator_context.R | 5 ++++ man/add_row.Rd | 8 ++++++- man/delete_selected_rows.Rd | 6 +++++ man/redo.Rd | 6 +++++ man/tabulatorContext.Rd | 6 +++++ man/trigger_download.Rd | 16 ++++++++++--- man/trigger_get_data.Rd | 6 +++++ man/trigger_get_sheet_data.Rd | 6 +++++ man/undo.Rd | 6 +++++ 10 files changed, 103 insertions(+), 7 deletions(-) diff --git a/R/context_calls.R b/R/context_calls.R index 6a88183..3036350 100644 --- a/R/context_calls.R +++ b/R/context_calls.R @@ -1,9 +1,18 @@ #' Download table data +#' +#' @details +#' If you want to provide xlsx downloads, you need to include +#' the sheetjs html dependency: \code{tabulator(..., sheetjs = TRUE)} #' @param ctx (\code{\link{tabulatorContext}}): tabulator context object -#' @param type (character): csv, json or xlsx (needs sheetjs: \code{tabulator(..., sheetjs = TRUE)}) +#' @param type (character): csv, json or xlsx #' @param file_name (character, \code{NULL}): File name. -#' @returns tabulator context object #' If \code{NULL}, it is set to \code{"data.{type}"}. +#' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' trigger_download("csv", "table-data.csv") +#' } #' @export trigger_download <- function(ctx, type = c("csv", "json", "xlsx"), file_name = NULL) { if (is.null(file_name)) { @@ -16,6 +25,11 @@ trigger_download <- function(ctx, type = c("csv", "json", "xlsx"), file_name = N #' Submit data to R #' @inheritParams trigger_download #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' trigger_get_data() +#' } #' @export trigger_get_data <- function(ctx) { invoke_method(ctx, "getData") @@ -23,8 +37,13 @@ trigger_get_data <- function(ctx) { #' Add row to table #' @inheritParams trigger_download -#' @param row (list | NULL): row data or \code{NULL} to add an empty row +#' @param row (list): row data or \code{NULL} to add an empty row #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' add_row() +#' } #' @export add_row <- function(ctx, row = NULL) { invoke_method(ctx, "addRow", row) @@ -33,6 +52,11 @@ add_row <- function(ctx, row = NULL) { #' Delete selected rows from table #' @inheritParams trigger_download #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' delete_selected_rows() +#' } #' @export delete_selected_rows <- function(ctx) { invoke_method(ctx, "deleteSelectedRows") @@ -47,6 +71,11 @@ delete_row <- function(ctx) { #' Undo changes #' @inheritParams trigger_download #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' undo() +#' } #' @export undo <- function(ctx) { invoke_method(ctx, "undo") @@ -55,6 +84,11 @@ undo <- function(ctx) { #' Redo changes #' @inheritParams trigger_download #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' redo() +#' } #' @export redo <- function(ctx) { invoke_method(ctx, "redo") @@ -63,6 +97,11 @@ redo <- function(ctx) { #' Submit sheet data to R #' @inheritParams trigger_download #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' trigger_get_sheet_data() +#' } #' @export trigger_get_sheet_data <- function(ctx) { invoke_method(ctx, "getSheetData") diff --git a/R/tabulator_context.R b/R/tabulator_context.R index d390588..97d9002 100644 --- a/R/tabulator_context.R +++ b/R/tabulator_context.R @@ -21,6 +21,11 @@ invoke_method <- function(widget, method_name, ...) { #' @param output_id (character): A tabulator output id. #' @param session A shiny session object. #' @returns tabulator context object +#' @examples +#' \dontrun{ +#' tabulatorContext("table") |> +#' trigger_download("csv") +#' } #' @export tabulatorContext <- function(output_id, session = shiny::getDefaultReactiveDomain()) { ctx <- list( diff --git a/man/add_row.Rd b/man/add_row.Rd index e4edbab..76421d3 100644 --- a/man/add_row.Rd +++ b/man/add_row.Rd @@ -9,7 +9,7 @@ add_row(ctx, row = NULL) \arguments{ \item{ctx}{(\code{\link{tabulatorContext}}): tabulator context object} -\item{row}{(list | NULL): row data or \code{NULL} to add an empty row} +\item{row}{(list): row data or \code{NULL} to add an empty row} } \value{ tabulator context object @@ -17,3 +17,9 @@ tabulator context object \description{ Add row to table } +\examples{ +\dontrun{ +tabulatorContext("table") |> + add_row() +} +} diff --git a/man/delete_selected_rows.Rd b/man/delete_selected_rows.Rd index d335b6b..ba8d8e0 100644 --- a/man/delete_selected_rows.Rd +++ b/man/delete_selected_rows.Rd @@ -15,3 +15,9 @@ tabulator context object \description{ Delete selected rows from table } +\examples{ +\dontrun{ +tabulatorContext("table") |> + delete_selected_rows() +} +} diff --git a/man/redo.Rd b/man/redo.Rd index dafff08..6b420b2 100644 --- a/man/redo.Rd +++ b/man/redo.Rd @@ -15,3 +15,9 @@ tabulator context object \description{ Redo changes } +\examples{ +\dontrun{ +tabulatorContext("table") |> + redo() +} +} diff --git a/man/tabulatorContext.Rd b/man/tabulatorContext.Rd index 683fe92..314a50d 100644 --- a/man/tabulatorContext.Rd +++ b/man/tabulatorContext.Rd @@ -20,3 +20,9 @@ Create a tabulator context object \details{ A \code{tabulatorContext} object makes it possible to update your widget in a Shiny application. } +\examples{ +\dontrun{ +tabulatorContext("table") |> + trigger_download("csv") +} +} diff --git a/man/trigger_download.Rd b/man/trigger_download.Rd index 2bb8211..a12f26a 100644 --- a/man/trigger_download.Rd +++ b/man/trigger_download.Rd @@ -9,14 +9,24 @@ trigger_download(ctx, type = c("csv", "json", "xlsx"), file_name = NULL) \arguments{ \item{ctx}{(\code{\link{tabulatorContext}}): tabulator context object} -\item{type}{(character): csv, json or xlsx (needs sheetjs: \code{tabulator(..., sheetjs = TRUE)})} +\item{type}{(character): csv, json or xlsx} -\item{file_name}{(character, \code{NULL}): File name.} +\item{file_name}{(character, \code{NULL}): File name. +If \code{NULL}, it is set to \code{"data.{type}"}.} } \value{ tabulator context object - If \code{NULL}, it is set to \code{"data.{type}"}. } \description{ Download table data } +\details{ +If you want to provide xlsx downloads, you need to include +the sheetjs html dependency: \code{tabulator(..., sheetjs = TRUE)} +} +\examples{ +\dontrun{ +tabulatorContext("table") |> + trigger_download("csv", "table-data.csv") +} +} diff --git a/man/trigger_get_data.Rd b/man/trigger_get_data.Rd index 9c02214..5fa9726 100644 --- a/man/trigger_get_data.Rd +++ b/man/trigger_get_data.Rd @@ -15,3 +15,9 @@ tabulator context object \description{ Submit data to R } +\examples{ +\dontrun{ +tabulatorContext("table") |> + trigger_get_data() +} +} diff --git a/man/trigger_get_sheet_data.Rd b/man/trigger_get_sheet_data.Rd index a312048..76f9ab8 100644 --- a/man/trigger_get_sheet_data.Rd +++ b/man/trigger_get_sheet_data.Rd @@ -15,3 +15,9 @@ tabulator context object \description{ Submit sheet data to R } +\examples{ +\dontrun{ +tabulatorContext("table") |> + trigger_get_sheet_data() +} +} diff --git a/man/undo.Rd b/man/undo.Rd index 08b9a9c..ecddf25 100644 --- a/man/undo.Rd +++ b/man/undo.Rd @@ -15,3 +15,9 @@ tabulator context object \description{ Undo changes } +\examples{ +\dontrun{ +tabulatorContext("table") |> + undo() +} +}