library(palmerpenguins)
penguinsExercises
Data
{palmerpenguins}
For these exercises we’ll be using the penguins data from the {palmerpenguins} R package. After installing the package, you can load it into R:
Exercises
Exercise 1: Building a basic app structure
Open up your IDE of choice.
Make sure you have the {shiny} package installed.
Create an
app.Rfile.Add
uiandserverelements, as well asshiny::shinyApp(ui, server).Check it works.
Solution
Exercise 2: Developing a user interface
Inside the
fluidPage()function, add a title panel, sidebar, and main panel.Add a drop down menu with
selectInput()to choose by Island.What happens if you use
checkboxGroupInput()instead?Bonus: add additional user options! See: mastering-shiny.org/basic-ui.html
Solution
Exercise 3: Adding reactive elements
Add a
reactive()in the server to subset the data based on the user input you created.Create a bar chart of number of penguins per species.
plotOutput()also works for {ggplot2} plots!Check your app runs.
Bonus: the default Shiny app styling is fine. Install and load the {shinythemes} package. Try adding
theme = shinytheme("cyborg")to the UI.Browse: rstudio.github.io/shinythemes