{"id":14068488,"url":"https://github.com/rjake/shinyobjects","last_synced_at":"2025-10-22T03:24:49.395Z","repository":{"id":38441077,"uuid":"250857587","full_name":"rjake/shinyobjects","owner":"rjake","description":"load reactive objects into global environment","archived":false,"fork":false,"pushed_at":"2022-06-03T20:41:25.000Z","size":2745,"stargazers_count":22,"open_issues_count":24,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-28T18:18:24.062Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rjake.github.io/shinyobjects","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rjake.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-28T17:45:27.000Z","updated_at":"2024-02-03T15:21:08.000Z","dependencies_parsed_at":"2022-08-18T11:32:53.809Z","dependency_job_id":null,"html_url":"https://github.com/rjake/shinyobjects","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjake%2Fshinyobjects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjake%2Fshinyobjects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjake%2Fshinyobjects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjake%2Fshinyobjects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjake","download_url":"https://codeload.github.com/rjake/shinyobjects/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228082310,"owners_count":17866603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:06:12.768Z","updated_at":"2025-10-22T03:24:44.337Z","avatar_url":"https://github.com/rjake.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n# shinyobjects \u003cimg src=\"man/figures/logo.png\" align=\"right\" alt=\"\" width=\"120\" /\u003e\n\u003c!-- [![Codecov test coverage](https://codecov.io/gh/rjake/simplecolors/branch/master/graph/badge.svg)](https://codecov.io/gh/rjake/simplecolors?branch=master)--\u003e\n\u003c!-- badges: start --\u003e\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/shinyobjects)](https://cran.r-project.org/package=shinyobjects)\n[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/shinyobjects)](https://cran.r-project.org/package=shinyobjects)\n  \u003c!-- badges: end --\u003e\n  \nTroubleshooting reactive data in a `shiny` app or `flexdashboard` can be difficult. The goal of this package is to access reactive objects in your local environment. This allows you to debug your code without having to run the app. It is my hope that this will save you time and allow you to iterate more quickly. \n\n### How does it work?\nThe package converts reactive data frames into functions that will read from your raw data and become available in your environment. The main function, `load_reactive_objects()`, will recommended that you create a dummy `input` list in your script to simulate reactive inputs. When you run `load_reactive_objects()`, it will prepopulate this list. You can learn more about dummy input lists in [this vignette](https://rjake.github.io/shinyobjects/articles/tips-and-tricks.html). The package also includes a function to view your UI elements in the viewer pane (see below).\n\n## Installation\nYou can install the released version of `shinyobjects` from [CRAN](https://cran.r-project.org/package=shinyobjects) with:\n\n``` r\ninstall.packages(\"shinyobjects\")\n```\n\nYou can install the development version from [GitHub](https://github.com/rjake/shinyobjects) with:\n\n``` r\ndevtools::install_github(\"rjake/shinyobjects\")\n```\n## Usage\nThere is a quick tutorial on [YouTube](https://youtu.be/_z_XeXT96Uw)\n\n\u003ca href=\"https://youtu.be/_z_XeXT96Uw\"\u003e\n  \u003cimg src=\"man/figures/youtube_thumbnail.png\"\u003e\n\u003c/a\u003e\n\n...but in words, the main function of `shinyobjects` is `load_reactive_objects()`. It is similar to running `source()` but with a lot of helpers to give you access to the reactive data. When you run it, your environment will have all your libraries, raw data and assignments, dummy `input`, `output` and `session` lists, and all `reactive()` assignments will be converted to functions. In the dev version (for 0.2.0), you also get access to your `render...()` objects in the dummy `output` list. With the dummy `input` list and the conversion of `reactive(x)` to `function() x`, the code will run your data manipulation referencing your dummy `input` list and it will be like writing a normal script. Note: **shinyobjects does not change your files**; the manipulation happens behind the scenes.\n\n\u003cimg src=\"man/figures/load_reactive_objects.png\"  width=600/\u003e\n\n```{r example, eval = FALSE}\nlibrary(shinyobjects)\n\n# If the app is open, the function will ask to use \n# the script currently active in the source pane\nload_reactive_objects()\n```\n\nThis will result in something like the following message\n```\nHere are the inputs you have listed:\n\n  input_name  times_used  lines  missing\n1      displ           1     45     TRUE\n2       year           2  48,49     TRUE\n\n\n# Add this code to your R file:\ndummy_input \u003c- list(\n  displ = \"\",\n  year = \"\"\n)\n```\n\nIf you are working on a `flexdashboard`, you will get a slightly different message to add a code chunk. Note this has `eval=FALSE` so it only runs when you need it for troubleshooting\n\n    #Add this code chunk to your Rmd:\n    ```{r input_demo, eval = FALSE}\")\n    input \u003c- list(\n      displ = \"\",\n      year = \"\"\n    )\n    ```\n\nIt will then ask you where to put the objects when it sources the script:\n```\nWARNING: Which environment do you want to use? \n\n1: Global\n2: New\n3: Cancel\n\nSelection:\n```\n\n**Be careful here** `load_reactive_objects()` will overwrite objects with the same name in your environment. \n\n\nHit `1` or `2` to select the environment. You can also specify the environment using the `envir = ...` argument.\n\nThe last prompt will confirm the file to use by looking in the source pane for the script you are currently working on.\n\n```\n1: Use current file: runapp.R\n2: Choose file in browser\n\nSelection: \n```\n\n\nThere are additional arguments you can use to restart R or to clear the environment. The `keep` argument takes a regular expression as the pattern match. To get an exact match, use the `^` and `$` to signify the beginning and end (ex. `^your_text$`). To list objects, separate them with a `|`. as shown below.\n\n```{r, eval = FALSE}\nload_reactive_objects(\n  ...,\n  restart = TRUE,\n  clear_environment = TRUE, \n  keep = \"test_|^df$|raw_data\" # objects to keep\n)\n```\n\n\nIf you made a small change to your reactive code, you can highlight the code in your source pane and run `convert_selection()` in the console.\n\n\u003cimg src=\"man/figures/convert_selection.png\"  width=400/\u003e\n\nThe package also has a function to view UI elements in a few ways:\n\nYou run `view_ui()` after sending the code the console. The html output will be used.\n\n\u003cimg src=\"man/figures/view_ui_after_output.png\"  width=600/\u003e\n\nYou can pipe it\n```{r, eval = FALSE}\nshiny::selectInput(\n  \"state\",\n  \"Choose a state:\",\n  list(\n    East = c(\"NY\", \"NJ\", \"CT\"),\n    West = c(\"WA\", \"OR\", \"CA\"),\n    Midwest = c(\"MN\", \"WI\", \"IA\")\n  )\n) %\u003e% view_ui(close_after = NULL)\n```\n\n\u003cimg src=\"man/figures/view_ui.png\"  width=600/\u003e\n\nNote that `close_after` is set to `NULL` in this example. The `view_ui()` function launches an app and defaults to closing after 5 seconds. You can adjusts how long it runs or use `NULL` and stop it manually by using the stop sign.:red_circle: \n\nYou can also highlight the code you want to view similar to `convert_selection()`.\n\u003cimg src='man/figures/view_ui_selection.png' width=500/\u003e\n\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjake%2Fshinyobjects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frjake%2Fshinyobjects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjake%2Fshinyobjects/lists"}