Package 'shinyobjects'

Title: Access Reactive Data Interactively
Description: Troubleshooting reactive data in 'shiny' can be difficult. These functions will convert reactive data frames into functions and load all assigned objects into your local environment. If you create a dummy input object, as the function will suggest, you will be able to test your server and ui functions interactively.
Authors: Jake Riley [aut, cre]
Maintainer: Jake Riley <[email protected]>
License: GPL-3
Version: 0.2.0
Built: 2025-02-01 03:42:26 UTC
Source: https://github.com/rjake/shinyobjects

Help Index


Convert and load the highlighted assignment to your environment

Description

After highlighting the assignment in the source editor, go to the console and run this function. The selected code will be run and if it is reactive, it will be loaded as a function.

Usage

convert_selection(envir = NULL)

Arguments

envir

the environment shinyobjects should the load the objects into.


Load inputs and convert reactive functions from an R/Rmd script to your environment

Description

This function will run all assignments of your R or Rmd. file In the process, this function will encourage the creation of a dummy input list that will mimic user input and allow your code to run. Lastly, reactive objects are converted to functions so they can still be called as df() etc.

Usage

load_reactive_objects(
  file,
  restart = FALSE,
  envir = NULL,
  clear_environment = FALSE,
  keep = NULL
)

Arguments

file

Rmd to be evaluated and loaded into your environment

restart

When TRUE, will restart the current R session. If you have R default to restore RData by default, you will need to use the clear_environment argument as well

envir

the environment shinyobjects should the load the objects into.

clear_environment

When TRUE, will remove objects not named in ...

keep

a regular expression of objects to keep when clear_environment = TRUE

Warning

This function has the ability to overwrite your objects in your environment. Make sure you understand how this function works before moving forward.

Examples

if (interactive()) {
  system.file(package = "shinyobjects", "Rmd/test_dashboard.Rmd") %>%
    load_reactive_objects()

  system.file(package = "shinyobjects", "Rmd/test_dashboard_no_inputs.Rmd") %>%
    load_reactive_objects()

  system.file(package = "shinyobjects", "Rmd/test_dashboard_missing_inputs.Rmd") %>%
    load_reactive_objects()
}

Show UI output in viewer pane

Description

Show UI output in viewer pane

Usage

view_ui(x, close_after = 5)

Arguments

x

ui content (actionButton, selectInput, valueBox), if x is not provided, view_ui() will look for selected text in the source pane or the last output from running the UI code. In the latter case, it expects an object with class "shiny.tag" or "shiny.tag.list"

close_after

number of seconds to display UI in Viewer panel. If NULL, app must be stopped manually before more code can be run.

Examples

if (interactive()) {
# run this line
shiny::selectInput(
  "state",
  "Choose a state:",
  list(
    `East Coast` = list("NY", "NJ", "CT"),
    `West Coast` = list("WA", "OR", "CA"),
    `Midwest` = list("MN", "WI", "IA")
  )
)
# the output will automatically be used here
view_ui(close_after = 6)
}