Described on the IT Services website
Announcements given via the Research IT blog and newsletter (sign up via the blog page) and on Twitter [@UoM_eResearch](http://twitter.com/uom_eresearch)
Get in touch via the support centre
R user groups are a great way of finding out more about R.
For example:
C:\work
Each step is separate labelled folder, which is cross referenced in the notes, e.g. 01_defaultapp.
The course website https://uomresearchit.github.io/r-shiny-course/ contains all the exercises, links to solutions and more detail than these slides.
If you’re happy using git:
git clone https://github.com/UoMResearchIT/r-shiny-course-materials.git
git checkout 01_defaultapp
rstudio
C:/work
and copy to your P drive at the end of the coursegapminder.rds
contains the gapminder dataworkshopFunctions.R
contains the functions we will use.
codeExample.R
shows how to use the plotting functions.ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins", ...
),
mainPanel(
plotOutput("distPlot")
)
)
)
input$bins
is a source
output$distPlot
is an endpoint
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
Shiny handles the dependencies between sources and endpoints, and only updates what is needed - Reactive programming.
gapminder.rds
) and workshopFunctions.R
to your app directoryModify the app to load the ggplot2 and dplyr libraries, gapminder data, and workshopFunctions.R
Check your app still works
(Course notes: Getting started)
checkboxGroupInput()
widget to select the continents we wish to display on the graphtitlePanel()
to something sensible(This won’t do anything yet - we’ll connect it to the graph shortly)
(Course notes: User interface design)
produceGapminderPlot()
04_gapminderplot
codeExample.R
(Course notes: Putting it all together)
Run from R(Studio)
(Course notes: Deploying Shiny apps)
sidebarLayout()
is a good starting point.fluidPage()
layout gives us more control.ui <- fluidPage(
titlePanel("Gapminder visualisation"), # Will cover whole width
plotOutput("gapminderPlot", click = "plotClick"), # Ditto
fluidRow(
column(6, # column width
sliderInput(inputId = "year", ....) # Things to include in the column
),
column(6, # Next column
checkboxGroupInput("continent", ....)# Things to include in second column
)
)
)