From f4b09ffca29a793aba01163b94d5cfc708d30038 Mon Sep 17 00:00:00 2001 From: Dean Attali Date: Tue, 17 May 2016 00:41:41 -0700 Subject: [PATCH] add a few more readmes --- README.md | 56 ++++++++++++++++----------------- busy-indicator/README.md | 3 ++ server-to-ui-variable/README.md | 3 ++ upload-file-names/README.md | 3 ++ 4 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 busy-indicator/README.md create mode 100644 server-to-ui-variable/README.md create mode 100644 upload-file-names/README.md diff --git a/README.md b/README.md index 1992b13..81111bf 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ R shiny tricks (shinyjs - reset inputs, disable, hide), global.R, global.R, splitting off big ui/server into files - +- [TODO complex directory structure](.) - [Simple AJAX system for Shiny apps (JS -> R -> JS communication)](#api-ajax) ([code](./api-ajax)) - [Automatically stop a Shiny app when closing the browser tab](#auto-kill-app) ([code](./auto-kill-app)) - [TODO](#busy-indicator) ([code](./busy-indicator)) @@ -20,57 +20,57 @@ global.R, splitting off big ui/server into files - [Press the Enter key to simulate a button press](#proxy-click) ([code](./proxy-click)) - [Select input with more breathing room](#select-input-large) ([code](./select-input-large)) - [Serve files (images/text files/etc) instead of webpages from a Shiny app ](#serve-images-files) ([code](./serve-images-files)) -- [TODO](#server-to-ui-variable) ([code](./server-to-ui-variable)) +- [Use a variable from the server in a UI `conditionalPanel()`](#server-to-ui-variable) ([code](./server-to-ui-variable)) - [Hide/show shinydashboard sidebar programatically](#shinydashboard-sidebar-hide) ([code](./shinydashboard-sidebar-hide)) - [Toggle a UI element (alternate between show/hide) with a button](#simple-toggle) ([code](./simple-toggle)) - [Update multiple Shiny inputs without knowing input type ](#update-input) ([code](./update-input)) -- [TODO](#upload-file-names) ([code](./upload-file-names)) +- [Fix filenames of files uploaded via fileInput()](#upload-file-names) ([code](./upload-file-names)) - [Prepopulate Shiny inputs when an app loads based on URL parameters](#url-inputs) ([code](./url-inputs)) -

Simple AJAX system for Shiny apps (JS -> R -> JS communication)

+

Simple AJAX system for Shiny apps (JS -> R -> JS communication)

**[Link to code](./api-ajax)** Sometimes it's useful to be able to call an R function from JavaScript and use the return value from R back in JavaScript. This sort of communication is usually done with AJAX in JavaScript. This app shows how to implement a simple and ultra lightweight AJAX-like system in Shiny, to be able to call functions in R. -

Automatically stop a Shiny app when closing the browser tab

+

Automatically stop a Shiny app when closing the browser tab

**[Link to code](./auto-kill-app)** When developing a Shiny app and running the app in the browser (as opposed to inside the RStudio Viewer), it can be annoying that when you close the browser window, the app is still running and you need to manually press "Esc" to kill it. By adding a single line to the server code `session$onSessionEnded(stopApp)`, a Shiny app will automatically stop running whenever the browser tab (or any session) is closed. -

TODO

+

TODO

**[Link to code](./busy-indicator)** -

Close the window (and stop the app) with a button click

+

Close the window (and stop the app) with a button click

**[Link to code](./close-window)** This simple example shows how you can have a button that, when clicked, will close the current browser tab and stop the running Shiny app (you can choose to do only one of these two actions). -

Show user a generic error message when a Shiny error occurs in an output

+

Show user a generic error message when a Shiny error occurs in an output

**[Link to code](./error-custom-message)** When a Shiny output encounters an error, the exact error message will be shown to the user in place of the output. This is generally a good feature because it's easier to debug when you know the exact error. But sometimes this is undesireable if you want to keep the specifics of what happened unknown to the user, and you prefer to just show the user a generic "Some error occurred; please contact us" message. This may sound counter intuitive, but you can actually do this with a tiny bit of CSS, as this example shows. -

Facebook login through JavaScript in Shiny

+

Facebook login through JavaScript in Shiny

**[Link to code](./fb-login)** This app shows how you can use the [AJAX-like system](./api-ajax) in Shiny to authorize a user using Facebook's JavaScript library and pass the user's information to R for processing. -

Sharing images on Facebook

+

Sharing images on Facebook

**[Link to code](./fb-share-img)** There are two ways to share images on Facebook: either using an image URL and a popup dialog, or by programatically supplying the Facebook API with a base64 encoded image. This example shows both. -

Hide a tab

+

Hide a tab

**[Link to code](./hide-tab)** @@ -78,7 +78,7 @@ This app demonstrates how `shinyjs` can be used to hide/show a specific tab in a [![Demo](./hide-tab/hide-tab.gif)](./hide-tab) -

Loading screen

+

Loading screen

**[Link to code](./loading-screen)** @@ -86,7 +86,7 @@ This simple app shows how to add a "Loading..." screen overlaying the main app w [![Demo](./loading-screen/loading-screen.gif)](./loading-screen) -

Shiny app with sequence of pages

+

Shiny app with sequence of pages

**[Link to code](./multiple-pages)** @@ -94,20 +94,20 @@ This app demonstrates how to write a Shiny app that has a sequence of different [![Demo](./multiple-pages/multiple-pages.gif)](./multiple-pages) -

Multiple scrollspy - advanced

+

Multiple scrollspy - advanced

**[Link to code](./multiple-scrollspy-advanced)** The Bootstrap *scrollspy* plugin does not support multiple scrollspy objects per page. This Shiny app demonstrates how to support scrollspy on multiple tabs by allowing each tab to have its own independent scrollspy control and using JavaScript to ensure only the scrollspy on the current tab is activated. -

Multiple scrollspy - basic

+

Multiple scrollspy - basic

**[Link to code](./multiple-scrollspy-basic)** The Bootstrap *scrollspy* plugin does not support multiple scrollspy objects per page. This Shiny app demonstrates how to support scrollspy on multiple tabs by having one common scrollspy control that gets updated via JavaScript whenever a tab is changed to reflect the contents of the new tab. - + **[Link to code](./navigate-history)** @@ -115,7 +115,7 @@ Sometimes it's nice to be able to support navigation within a Shiny app, especia [![Demo](./navigate-history/navigate-history.gif)](./navigate-history) -

Show a spinning "loading" animation while a plot is recalculating

+

Show a spinning "loading" animation while a plot is recalculating

**[Link to code](./plot-spinner)** @@ -123,13 +123,13 @@ When a Shiny plot is recalculating, the plot gets grayed out. This app shows how [![Demo](./plot-spinner/plot-spinner.gif)](./plot-spinner) -

Press the Enter key to simulate a button press

+

Press the Enter key to simulate a button press

**[Link to code](./proxy-click)** This is a simple app with a tiny bit of JavaScript that shows you how to cause an Enter key press inside an input to trigger a click on a button. -

Select input with more breathing room

+

Select input with more breathing room

**[Link to code](./select-input-large)** @@ -137,7 +137,7 @@ One common CSS question in Shiny is how to make the select input dropdown menu h [![Demo](./select-input-large/selectize-large.gif)](./select-input-large) -

Serve files (images/text files/etc) instead of webpages from a Shiny app

+

Serve files (images/text files/etc) instead of webpages from a Shiny app

**[Link to code](./serve-images-files)** @@ -145,13 +145,13 @@ It is possible to serve an image or another file directly from your Shiny app in [![Demo](./serve-images-files/serve-images-files.gif)](./serve-images-files) -

TODO

+

Use a variable from the server in a UI `conditionalPanel()`

**[Link to code](./server-to-ui-variable)** +When using a conditional panel in the UI, the condition is usually an expression that uses an input value. But what happens when you want to use a conditional panel with a more complex condition that is not necessarily directly related to an input field? This example shows how to define an output variable in the server code that you can use in the UI. An alternative approach is to use the `show()` and `hide()` functions from the [shinyjs](https://github.com/daattali/shinyjs) package. - -

Hide/show shinydashboard sidebar programatically

+

Hide/show shinydashboard sidebar programatically

**[Link to code](./shinydashboard-sidebar-hide)** @@ -159,25 +159,25 @@ A common question regarding `shinydashboard` is how to programatically hide/show [![Demo](./shinydashboard-sidebar-hide/shinydashboard-sidebar-hide.gif)](./shinydashboard-sidebar-hide) -

Toggle a UI element (alternate between show/hide) with a button

+

Toggle a UI element (alternate between show/hide) with a button

**[Link to code](./simple-toggle)** Sometimes you want to toggle a section of the UI every time a button is clicked. This app shows how to achieve very basic toggle functionality using `conditionalPanel()`. If you want anything more advanced, you can use the `toggle()` function from the [shinyjs](https://github.com/daattali/shinyjs) package. -

Update multiple Shiny inputs without knowing input type

+

Update multiple Shiny inputs without knowing input type

**[Link to code](./update-input)** Shiny allows you to update an input element only if you know the type of input. Furthermore, Shiny only allows you to update input elements one by one. This Shiny app shows how you can update an input only using its ID and without knowing its type, and how to update multiple inputs together. -

TODO

+

Fix filenames of files uploaded via fileInput()

**[Link to code](./upload-file-names)** +When selecting files using a `fileInput()`, the filenames of the selected files are not retained. This is not usually a problem because usually you only care about the contents of a file and not its name. But sometimes you may actually need to know the original name of each selected file. This example shows how to write a simple function `fixUploadedFilesNames()` to rename uploaded files back to their original names. - -

Prepopulate Shiny inputs when an app loads based on URL parameters

+

Prepopulate Shiny inputs when an app loads based on URL parameters

**[Link to code](./url-inputs)** diff --git a/busy-indicator/README.md b/busy-indicator/README.md new file mode 100644 index 0000000..82e4db1 --- /dev/null +++ b/busy-indicator/README.md @@ -0,0 +1,3 @@ +# "Busy..." / "Done!" / "Error" + +[![Demo](./busy-indicator.gif)](./busy-indicator.gif) \ No newline at end of file diff --git a/server-to-ui-variable/README.md b/server-to-ui-variable/README.md new file mode 100644 index 0000000..6434f55 --- /dev/null +++ b/server-to-ui-variable/README.md @@ -0,0 +1,3 @@ +# Use a variable from the server in a UI `conditionalPanel()` + +When using a conditional panel in the UI, the condition is usually an expression that uses an input value. But what happens when you want to use a conditional panel with a more complex condition that is not necessarily directly related to an input field? This example shows how to define an output variable in the server code that you can use in the UI. An alternative approach is to use the `show()` and `hide()` functions from the [shinyjs](https://github.com/daattali/shinyjs) package. \ No newline at end of file diff --git a/upload-file-names/README.md b/upload-file-names/README.md new file mode 100644 index 0000000..3c5c8a3 --- /dev/null +++ b/upload-file-names/README.md @@ -0,0 +1,3 @@ +# Fix filenames of files selected via fileInput() + +When selecting files using a `fileInput()`, the filenames of the selected files are not retained. This is not usually a problem because usually you only care about the contents of a file and not its name. But sometimes you may actually need to know the original name of each selected file. This example shows how to write a simple function `fixUploadedFilesNames()` to rename uploaded files back to their original names. \ No newline at end of file