Package 'shinypal'

Title: Tools to Make Modular and Interactive R Workflow Builders
Description: Contains tools to develop and run modular and interactive shiny apps that use shinymeta to translate GUI-based pipelines into R and RMarkdown code.
Authors: William Gearty [aut, cre] (ORCID: <https://orcid.org/0000-0003-0076-3262>)
Maintainer: William Gearty <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9000
Built: 2026-06-05 01:04:41 UTC
Source: https://github.com/willgearty/shinypal

Help Index


Accordion panel that includes a remove button

Description

Accordion panel that includes a remove button

Usage

accordion_panel_remove_button(ind, ...)

Arguments

ind

The index of the step.

...

Additional arguments passed to bslib::accordion_panel().


Add a step to the report, workflow, and the code chain

Description

A short description...

Usage

add_shinypal_step(
  input,
  ind,
  fun_workflow,
  fun_report,
  code_chain_list,
  libs,
  ec_subs = NULL
)

Arguments

input

The input object from the shiny app.

ind

The index of the step to be added.

fun_workflow

A function that generates the UI elements for the workflow.

fun_report

A function that generates the UI elements for the report.

code_chain_list

A list of quoted code bits that will be added to code_chain().

libs

A character vector of R packages required for this step.

ec_subs

An optional list of length 2, where the first element is a metaReactive object and the second element is a callback function. This is used to substitute expansion contexts in the code chain.


Add an observer to a copy button

Description

Generates an event observer that watches for when a copy button is clicked. Upon clicking, the code_expr is evaluated and copied to the clipboard using clipr::write_clip().

Usage

clip_observe(input, output, ind, code_expr)

Arguments

input

The shiny input object.

output

The shiny output object.

ind

The index of the step.

code_expr

An expression (generated by rlang::expr() that, when evaluated, returns content to be copied (such as the output from shinymeta::expandChain().


Keep a varSelectInput of data.frame column names up-to-date

Description

Keep a varSelectInput of data.frame column names up-to-date

Usage

column_select_observe(input, ind, inputId)

Arguments

input

The shiny input object.

ind

The index of the step.

inputId

The id of the shiny::varSelectInput() object.


Button to show dataframe modal

Description

Generates a shiny::actionButton() that, when clicked, generates a modal for the resulting dataset for the specified step. Make sure to set up a corresponding observer using df_modal_observe().

Usage

df_modal_button(ind, text = "View data")

Arguments

ind

The index of the step.

text

The text to display on the button.


Show a modal with a reactable data.frame

Description

Show a modal with a reactable data.frame

Usage

df_modal_observe(input, output, ind, df_name)

Arguments

input

The shiny input object.

output

The shiny output object.

ind

The index of the step.

df_name

The name of the data.frame to be displayed.


Keep a selectInput of intermediate data.frames up-to-date

Description

Keep a selectInput of intermediate data.frames up-to-date

Usage

df_select_observe(input, ind)

Arguments

input

The shiny input object.

ind

The index of the step.


Observe a file input to be included in the download bundle

Description

Observe a file input to be included in the download bundle

Usage

file_observe(input, inputId)

Arguments

input

The shiny input object.

inputId

The id of the shiny::fileInput() object. of the file in the code.


Get the expanded code chunk for a registered step

Description

Returns the code chunk for ind, expanded with a shared context across all currently-registered steps. Use this inside a reactive consumer (e.g., renderPrint(), observeEvent()) to display or copy a step's code. The chunk is rebuilt whenever any dependency changes.

Usage

get_chunk(ind)

Arguments

ind

The index of the step.

Value

A code object suitable for printing or passing to shinymeta::displayCodeModal(), or NULL if the step is not registered.


Generate a background color and font color for a step based on its index

Description

Generate a background color and font color for a step based on its index

Usage

get_colors(ind)

Arguments

ind

The index of the step.

Value

A list containing the color and background CSS styles for the step.


Get an intermediate data object

Description

Get an intermediate data object

Usage

get_int_data(name)

Arguments

name

The name of the data object to retrieve.


Get the names of all intermediate data.frames for a given step

Description

Get the names of all intermediate data.frames for a given step

Usage

get_int_dfs(ind)

Arguments

ind

The index of the step.


Get the next workflow step index

Description

Returns a unique, monotonically increasing index for a new workflow step. Each call increments a server-side counter. The counter is initialised by shinypal_setup() and is deliberately never reset while the session is running.

Usage

next_step_index()

Value

A single positive integer to use as the new step's index.


Select input to choose a column from a specified dataset

Description

This should be paired with select_dataset_input().

Usage

select_column_input(ind, label = "Choose a column:", default = NULL, ...)

Arguments

ind

The index of the step.

label

The label for the select input.

default

The default value for the select input.

...

Additional arguments passed to shiny::varSelectInput().


Select input to choose a shinypal intermediate dataset

Description

Select input to choose a shinypal intermediate dataset

Usage

select_dataset_input(ind, label = "Choose a dataset:")

Arguments

ind

The index of the step.

label

The label for the select input.


Set an intermediate data object

Description

Set an intermediate data object

Usage

set_int_data(obj, name)

Arguments

obj

A reactive data object to store.

name

A name to store data object as.


Setup shinypal

Description

A function to set up the shinypal environment. This function should be called at the top of the server function of your shiny app.

Usage

shinypal_setup(
  input,
  output,
  session,
  modules,
  download_filename = "shinypal_script.zip",
  download_template = "./modules/test_report.qmd"
)

Arguments

input

The shiny input object.

output

The shiny output object.

session

The shiny session object.

modules

A character vector of paths to independent modules.

download_filename

The name of the file to download when the user clicks the download button.

download_template

The path to the Quarto markdown template file that will be used to generate the report.

Details

Each module should have a ui-aux.R file that defines the UI elements for that module in the "Workflow" accordion and a server.R file that defines the server-side logic for the module.


UI for ShinyPal

Description

A function to create the UI for the ShinyPal app. This function should be called in the UI function of your shiny app.

Usage

shinypal_ui(modules)

Arguments

modules

A character vector of paths to independent modules.

Details

Each module should have a ui-main.R file that defines the UI elements for that module in the "Steps" accordion.


Text element with a button to copy the code to the clipboard

Description

Render a reactive output variable as text within an application page. Uses shiny::verbatimTextOutput() which is usually paired with shiny::renderPrint() and provides fixed-width text in a ⁠<pre>⁠. Make sure to set up a corresponding observer using clip_observe().

Usage

verbatimTextOutput_copy(ind)

Arguments

ind

The index of the step.