2 hour hands-on workshop on how to create, deploy and use Shiny in research and teaching. The materials for the workshop are https://languagevariationsuite.wordpress.com/2018/11/27/introduction-to-interactive-shiny-web-applications
2. Objectives
Learn and practice R/Shiny basics
Explore Shiny templates and widgets
Create and deploy an interactive web application
Learn about Shiny apps for research and in teaching
5. What is RStudio?
RStudio is an open source “set of integrated tools to help you
be more productive with R”
Shiny is a package from RStudio to build interactive web
interfaces/pages/applications
26. Run
Shiny Demo
Run Demo in R script
FIRST LINE of YOUR SCRIPT (top left panel)
TYPE:
runExample(“04_mpg”)
46
27. Run
Shiny Demo
Run Demo in R script
How to RUN your commands from the R script:
Keep your cursor at the FIRST LINE
Select RUNPlace cursor on the line or
select runExample(“04_mpg”)
47
28. Run
Shiny Demo
Run Demo in R script Demo in the Browser
Place cursor on the line or
select runExample(“04_mpg”)
48
29. Closing Demo App
Click STOP sign in your CONSOLE (bottom left). Your browser viewer will turn grey.
49
30. A Closer Look at the Shiny App
runExample("04_mpg")
Shiny script is called app.R
It activates TWO libraries (packages)
Use # (hashtag) to make comments
50
34. A Closer Look at the Shiny Interactivity
54
Change Variable
INPUT OUTPUT
35. Practice 1: Open Shiny App
Download and unzip 082-word-cloud.zip
Set Directory to 082-word-cloud folder
Find a file UI.R
Open UI.R (File > Open File > Open)
55
https://github.com/rstudio/shiny-examples/tree/master/082-word-cloud
42. Change Title
Add subtitle h2()
Add line break br()
Add horizontal line hr()
Save File (File>Save)
RunApp
Practice 3: HTML Title Panel
Do NOT forget COMMAS
53. Widgets
- Widget may have additional options, e.g. selected=, value=
- Widgets can be placed in sidebarPanel or mainPanel
54. Widget Content
- Each widget requires two arguments:
- a name of the widget (=id)
- a label (a text that appears in the app)
fileInput("file", "File input:")
name:
label:
file
File input
55. Unzip and Open workshopshiny-final
- RunApp
- Identify UI elements
- What are two widgets in your
App? Where are they?
59. Reactive Input Data in SERVER.R
- This function will read
a csv file
- This function will
renders a table
- Input file will come
from UI.R when csv is
uploaded
65. Deployment on Jetstream
Pros:
You can have a persistent Shiny app available for no charge.
Can handle short-term high usage.
Help is available
Cons:
Need to request allocation from XSEDE.
Need to keep it running.
Will need to use Linux command line.
66. Research and Teaching
Customizable Online Tools:
Statistics, Visualization, Data Preprocessing
languagevariationsuite.cominteractivetextminingsuite.com