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 |
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.
convert_selection(envir = NULL)
convert_selection(envir = NULL)
envir |
the environment shinyobjects should the load the objects into. |
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.
load_reactive_objects( file, restart = FALSE, envir = NULL, clear_environment = FALSE, keep = NULL )
load_reactive_objects( file, restart = FALSE, envir = NULL, clear_environment = FALSE, keep = NULL )
file |
Rmd to be evaluated and loaded into your environment |
restart |
When |
envir |
the environment shinyobjects should the load the objects into. |
clear_environment |
When |
keep |
a regular expression of objects to keep when |
This function has the ability to overwrite your objects in your environment. Make sure you understand how this function works before moving forward.
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() }
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
view_ui(x, close_after = 5)
view_ui(x, close_after = 5)
x |
ui content (actionButton, selectInput, valueBox), if x is not provided, |
close_after |
number of seconds to display UI in Viewer panel. If NULL, app must be stopped manually before more code can be run. |
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) }
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) }