-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c7e6c6
commit 2714bbb
Showing
281 changed files
with
1,025 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file renamed
BIN
+13.3 MB
...01-getting-started/01-getting-started.pdf → materials/01-starting/01-starting.pdf
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Load packages ---------------------------------------------------------------- | ||
library(shiny) | ||
library(tidyverse) | ||
|
||
# Load data -------------------------------------------------------------------- | ||
load("movies.Rdata") | ||
|
||
# Define UI for application that plots features of movies ---------------------- | ||
ui <- fluidPage( | ||
|
||
# Application title ---------------------------------------------------------- | ||
titlePanel("Movie browser"), | ||
|
||
# Sidebar layout with a input and output definitions ------------------------- | ||
sidebarLayout( | ||
|
||
# Inputs: Select variables to plot ----------------------------------------- | ||
sidebarPanel( | ||
|
||
# Select variable for y-axis --------------------------------------------- | ||
selectInput(inputId = "y", | ||
label = "Y-axis:", | ||
choices = c("IMDB rating" = "imdb_rating", | ||
"IMDB number of votes" = "imdb_num_votes", | ||
"Critics Score" = "critics_score", | ||
"Audience Score" = "audience_score", | ||
"Runtime" = "runtime"), | ||
selected = "audience_score"), | ||
|
||
# Select variable for x-axis --------------------------------------------- | ||
selectInput(inputId = "x", | ||
label = "X-axis:", | ||
choices = c("IMDB rating" = "imdb_rating", | ||
"IMDB number of votes" = "imdb_num_votes", | ||
"Critics Score" = "critics_score", | ||
"Audience Score" = "audience_score", | ||
"Runtime" = "runtime"), | ||
selected = "critics_score"), | ||
|
||
# Select variable for color ---------------------------------------------- | ||
selectInput(inputId = "z", | ||
label = "Color by:", | ||
choices = c("Title Type" = "title_type", | ||
"Genre" = "genre", | ||
"MPAA Rating" = "mpaa_rating", | ||
"Critics Rating" = "critics_rating", | ||
"Audience Rating" = "audience_rating"), | ||
selected = "mpaa_rating"), | ||
|
||
# Set alpha level -------------------------------------------------------- | ||
sliderInput(inputId = "alpha", | ||
label = "Alpha:", | ||
min = 0, max = 1, | ||
value = 0.5) | ||
|
||
), | ||
|
||
# Output ------------------------------------------------------------------- | ||
mainPanel( | ||
|
||
# Show scatterplot ------------------------------------------------------- | ||
plotOutput(outputId = "scatterplot"), | ||
|
||
# Show data table -------------------------------------------------------- | ||
DT::dataTableOutput(outputId = "moviestable") | ||
) | ||
) | ||
) | ||
|
||
# Define server function required to create the scatterplot -------------------- | ||
server <- function(input, output) { | ||
|
||
# Create scatterplot object the plotOutput function is expecting ------------- | ||
output$scatterplot <- renderPlot({ | ||
ggplot(data = movies, aes_string(x = input$x, y = input$y, | ||
color = input$z)) + | ||
geom_point(alpha = input$alpha) + | ||
labs(x = toTitleCase(str_replace_all(input$x, "_", " ")), | ||
y = toTitleCase(str_replace_all(input$y, "_", " ")), | ||
color = toTitleCase(str_replace_all(input$z, "_", " "))) | ||
}) | ||
|
||
# Print data table if checked ------------------------------------------------ | ||
output$moviestable <- DT::renderDataTable({ | ||
DT::datatable(data = movies[, 1:7], | ||
options = list(pageLength = 10), | ||
rownames = FALSE) | ||
}) | ||
} | ||
|
||
# Create the Shiny app object -------------------------------------------------- | ||
shinyApp(ui = ui, server = server) |
Oops, something went wrong.