Skip to content

Commit

Permalink
11 cran (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
shajoezhu and github-actions[bot] authored Nov 27, 2024
1 parent c685541 commit 51a7625
Show file tree
Hide file tree
Showing 62 changed files with 207 additions and 44 deletions.
7 changes: 7 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ R/util_experimental.R
^_pkgdown\.yml$
^docs$
^pkgdown$
LICENSE

# dev
tmp/
ae.pptx
ae_summary.pptx
dd.pptx
dm.pptx
dor.pptx
‘output.pptx’
16 changes: 12 additions & 4 deletions DESCRIPTION
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: autoslider.core
Title: Slides automation with R
Version: 0.0.1.9033
Title: Slide Automation for Tables, Listings and Figures
Version: 0.1.0
Authors@R: c(
person("Joe", "Zhu", , "[email protected]", role = c("cre", "aut")),
person("Heng", "Wang", role = "aut"),
Expand All @@ -20,9 +20,17 @@ Authors@R: c(
person("Elisabeth", "Deutschmann", role = "ctb"),
person("Chenkai", "Lv", role = "aut")
)
Description: Slides automation with R.
License: file LICENSE
Description: The normal process of creating clinical study slides is that a statistician
manually type in the numbers from outputs and a separate statistician to double check
the typed in numbers. This process is time consuming, resource intensive, and error
prone. Automatic slide generation is a solution to address these issues. It reduces the
amount of work and the required time when creating slides, and reduces the risk of
errors from manually typing or copying numbers from the output to slides. It also
helps users to avoid unnecessary stress when creating large amounts of slide decks
in a short time window.
License: Apache License 2.0
URL: https://github.com/insightsengineering/autoslider.core
BugReports: https://github.com/insightsengineering/autoslider.core/issues
Depends:
flextable (>= 0.9.4),
officer (>= 0.3.18),
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# autoslider.core 0.0.1.9033
# autoslider.core 0.1.0

### Miscellaneous
* First release.
1 change: 1 addition & 0 deletions R/autoslideR_error.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param x character scaler
#' @param spec spec should be a list containing "program" and "suffix"
#' @param step step is a character indicating in which step the pipeline encounter error
#' @return autoslider_error object
#' @export
autoslider_error <- function(x, spec, step) {
assert_is_character_scalar(x)
Expand Down
16 changes: 11 additions & 5 deletions R/decorate.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' generic function decorate
#' @return No return value, called for side effects
#' @export
setGeneric("decorate", function(x, ...) standardGeneric("decorate"))

Expand All @@ -12,7 +13,7 @@ decorate <- function(x, ...) {
#' default method to decorate
#' @param x object to decorate
#' @param ... additional arguments. not used.
#'
#' @return No return value, called for side effects
#' @export
decorate.default <- function(x, ...) {
stop("default decorate function does not exist")
Expand All @@ -21,7 +22,7 @@ decorate.default <- function(x, ...) {
#' decorate method for autoslider_error class
#' @param x object to decorate
#' @param ... additional arguments. not used.
#'
#' @return No return value, called for side effects
#' @export
decorate.autoslider_error <- function(x, ...) {
x
Expand All @@ -35,6 +36,7 @@ decorate.autoslider_error <- function(x, ...) {
#' @param paper Orientation and font size as string, e.g. "P8"; "L11"
#' @param for_test `logic` CICD parameter
#' @param ... Additional arguments passed to the decoration function.
#' @return No return value, called for side effects
setMethod(
"decorate", "VTableTree",
decorate.VTableTree <- function(x, titles = "", footnotes = "", paper = "P8", for_test = FALSE, ...) {
Expand Down Expand Up @@ -74,6 +76,7 @@ setMethod(
#' @param paper Paper size, by default "L11"
#' @param for_test `logic` CICD parameter
#' @param ... additional arguments. not used.
#' @return No return value, called for side effects
#' @details
#' The paper default paper size, `L11`, indicate that the fontsize is 11.
#' The fontsize of the footnotes, is the fontsize of the titles minus 2.
Expand All @@ -97,6 +100,7 @@ decorate.ggplot <- function(x, titles = "", footnotes = "", paper = "L11", for_t
#' @param paper Orientation and font size as string, e.g. "P8"; "L11"
#' @param for_test `logic` CICD parameter
#' @param ... Additional arguments. not used.
#' @return No return value, called for side effects
setMethod(
"decorate", "listing_df",
decorate.listing_df <- function(x, titles = "", footnotes = "", paper = "P8", for_test = FALSE, ...) {
Expand Down Expand Up @@ -134,6 +138,7 @@ setMethod(
#' @param paper paper size. default is "L8".
#' @param for_test `logic` CICD parameter
#' @param ... Additional arguments. not used.
#' @return No return value, called for side effects
#' @details
#' The paper default paper size, `L11`, indicate that the fontsize is 11.
#' The fontsize of the footnotes, is the fontsize of the titles minus 2.
Expand Down Expand Up @@ -165,6 +170,7 @@ decorate.grob <-
#' @details
#' The paper default paper size, `L11`, indicate that the fontsize is 11.
#' The fontsize of the footnotes, is the fontsize of the titles minus 2.
#' @return No return value, called for side effects
#' @export
#'
decorate.list <-
Expand Down Expand Up @@ -204,7 +210,7 @@ decorate.list <-
#' @param generic_footnote `character` vector of footnotes
#' @param version_label `character`. A version label to be added to the title.
#' @param for_test `logic` CICD parameter
#'
#' @return No return value, called for side effects
#' @details
#' `generic_title` and `generic_footnote` will be added to *all* outputs. The use
#' case is to add information such as protocol number and snapshot date defined
Expand Down Expand Up @@ -284,7 +290,7 @@ decorate_outputs <- function(outputs,
#'
#' @param x An object of class `decoratedGrob`
#' @param ... not used.
#'
#' @return No return value, called for side effects
#' @export
print.decoratedGrob <- function(x, ...) {
grid::grid.newpage()
Expand All @@ -295,7 +301,7 @@ print.decoratedGrob <- function(x, ...) {
#'
#' @param x An object of class `decoratedGrobSet`
#' @param ... not used.
#'
#' @return No return value, called for side effects
#' @export
print.decoratedGrobSet <- function(x, ...) {
for (plot in x) {
Expand Down
1 change: 1 addition & 0 deletions R/fastdocall.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param quote a logical value indicating whether to quote the arguments.
#' @param envir an environment within which to evaluate the call. This will be most useful if what is a character
#' string and the arguments are symbols or quoted expressions.
#' @return No return value, called for side effects
#' @export
fastDoCall <-
function(what,
Expand Down
2 changes: 1 addition & 1 deletion R/ft_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NULL
#' @param font_name Font name, default to arial
#' @param body_font_size Font size of the table content, default to 12
#' @param header_font_size Font size of the table header, default to 14
#'
#' @return A flextable with applied theme.
#' @export
autoslider_format <- function(ft,
odd_header = "#0EAED5", # "deepskyblue2",
Expand Down
2 changes: 2 additions & 0 deletions R/generate_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @param datasets list of datasets
#' @param spec spec
#' @param verbose_level Verbose level of messages be displayed. See details for further information.
#' @return No return value, called for side effects
#' @details
#' `verbose_level` is used to control how many messages are printed out.
#' By default, `2` will show all filter messages and show output generation message.
Expand Down Expand Up @@ -89,6 +90,7 @@ generate_output <-
#' @param spec Specification list generated by `read_spec`
#' @param datasets A `list` of datasets
#' @param verbose_level Verbose level of messages be displayed. See details for further information.
#' @return No return value, called for side effects
#' @details
#' `verbose_level` is used to control how many messages are printed out.
#' By default, `2` will show all filter messages and show output generation message.
Expand Down
6 changes: 3 additions & 3 deletions R/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param arm_var Arm variable
#' @param levels factor levels
#' @param labels factor labels
#'
#' @return Dataframe with re-level and re-labelled arm variable.
#' @export
mutate_actarm <- function(df,
arm_var = "TRT01A",
Expand All @@ -25,7 +25,7 @@ mutate_actarm <- function(df,
#' @param df Input dataframe
#' @param levels factor levels
#' @param labels factor labels
#'
#' @return dataframe
#' @export
preprocess_t_dd <- function(df,
levels = c("PROGRESSIVE DISEASE", "ADVERSE EVENT", "OTHER", "<Missing>"),
Expand Down Expand Up @@ -55,7 +55,7 @@ preprocess_t_dd <- function(df,
#' @param df Input dataframe
#' @param levels factor levels
#' @param labels factor labels
#'
#' @return dataframe
#' @export
preprocess_t_ds <- function(df,
levels = c("Alive: On Treatment", "Alive: In Follow-up", "<Missing>"),
Expand Down
2 changes: 1 addition & 1 deletion R/null_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @details
#' This will create a null report similar as STREAM does. You can use
#' it inside output functions as shown in the example below.
#'
#' @return An empty `rtables` object
#' @examples
#' library(dplyr)
#' library(filters)
Expand Down
6 changes: 5 additions & 1 deletion R/save_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ save_output <- function(output, file_name, save_rds = TRUE) {
}

#' @rdname save_output
#' @return No return value, called for side effects
#' @export
save_output.autoslider_error <- function(output,
file_name,
Expand All @@ -53,6 +54,7 @@ setMethod("save_output", "dVTableTree", save_output.dVTableTree <- function(outp
})

#' @rdname save_output
#' @return The input `object` invisibly
#' @export
save_output.decoratedGrob <- function(output,
file_name,
Expand All @@ -65,6 +67,7 @@ save_output.decoratedGrob <- function(output,
}

#' @rdname save_output
#' @return The input `object` invisibly
#' @export
save_output.decoratedGrobSet <- function(output, file_name, save_rds = TRUE) {
if (save_rds) {
Expand All @@ -76,6 +79,7 @@ save_output.decoratedGrobSet <- function(output, file_name, save_rds = TRUE) {


#' @rdname save_output
#' @return The input `object` invisibly
#' @export
save_output.dlisting <- function(output, file_name, save_rds = TRUE) {
if (save_rds) {
Expand All @@ -96,7 +100,7 @@ save_output.dlisting <- function(output, file_name, save_rds = TRUE) {
#' in addition to `.out` or `.pdf` files? Defaults to `FALSE`.
#' @param generic_suffix generic suffix. must be length 1 character or NULL.
#' @export
#'
#' @return The input `object` invisibly
#' @examples
#' ## As `save_outputs` is the last step in the pipeline we have to run
#' ## the 'whole machinery' in order to show its functionality. Also take a look
Expand Down
4 changes: 0 additions & 4 deletions R/spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ validate_spec <- function(spec) {
#' library(dplyr)
#' spec_file <- system.file("spec.yml", package = "autoslider.core")
#' spec <- spec_file %>% read_spec()
#' ## Keep only outputs belonging to batch 2
#' \dontrun{
#' filter_spec(spec, batch == 2)
#' }
#'
#' ## Keep only the t_dm_IT output
#' filter_spec(spec, output == "t_dm_IT")
Expand Down
2 changes: 1 addition & 1 deletion R/t_ae_pt_slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' )
#' out <- t_ae_pt_slide(adsl, adae, "TRT01A", 2)
#' print(out)
#' generate_slides(out, "ae.pptx")
#' generate_slides(out, paste0(tempdir(), "/ae.pptx"))
#'
#' # Example 2, prune by total column
#' out2 <- t_ae_pt_slide(adsl, adae, "TRT01A", 25, prune_by_total = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/t_ae_pt_soc_slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' )
#' out <- t_ae_pt_soc_slide(adsl, adae, "TRT01A", 2)
#' print(out)
#' generate_slides(out, "ae.pptx")
#' generate_slides(out, paste0(tempdir(), "/ae.pptx"))
#'
#'
#' # Example 2, prune by total column
Expand Down
2 changes: 1 addition & 1 deletion R/t_dor_slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param arm Arm variable, character, "`TRT01P" by default.
#' @param refgroup Reference group
#' @inherit gen_notes note
#'
#' @return An `rtables` object
#' @export
#' @examples
#' library(dplyr)
Expand Down
7 changes: 4 additions & 3 deletions R/to_slides.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @param l_cpp An integer specifying the listing columns per page\cr
#' Specify this optional argument to modify the width of all of the listings display
#' @param ... arguments passed to program
#' @return No return value, called for side effects
#' @export
#' @examples
#'
Expand Down Expand Up @@ -44,7 +45,7 @@
#' t_dm_slide(adsl, "TRT01P", c("SEX", "AGE")) %>%
#' generate_slides()
generate_slides <- function(outputs,
outfile = "output.pptx",
outfile = paste0(tempdir(), "/output.pptx"),
template = file.path(system.file(package = "autoslider.core"), "theme/basic.pptx"),
fig_width = 9, fig_height = 6, t_lpp = 20, t_cpp = 200, l_lpp = 20, l_cpp = 150, ...) {
if (any(c(
Expand Down Expand Up @@ -117,6 +118,7 @@ generate_slides <- function(outputs,
#' Generate flextable for preview first page
#'
#' @param x rtables or data.frame
#' @return A flextable or a ggplot object depending to the input.
#' @export
#' @examples
#' # Example 1. preview table
Expand Down Expand Up @@ -149,7 +151,6 @@ get_body_bottom_location <- function(ppt) {
#' @param ft Flextable object
#' @param ppt_width Powerpoint width
#' @param ppt_height Powerpoint height
#'
#' @return Location for a placeholder
center_table_loc <- function(ft, ppt_width, ppt_height) {
top <- 0.17 * ppt_height
Expand Down Expand Up @@ -259,7 +260,7 @@ center_figure_loc <- function(fig_width, fig_height, ppt_width, ppt_height) {
#' @param fig_width width of figure
#' @param fig_height height of figure
#' @param figure_loc location of figure
#'
#' @return Location for a placeholder
#' @export
ph_with_img <- function(ppt, figure, fig_width, fig_height, figure_loc) {
file_name <- tempfile(fileext = ".svg")
Expand Down
Loading

0 comments on commit 51a7625

Please sign in to comment.