Skip to content

Commit

Permalink
Reorg, take N!
Browse files Browse the repository at this point in the history
  • Loading branch information
mine-cetinkaya-rundel committed Jan 16, 2019
1 parent 6c7e6c6 commit 2714bbb
Show file tree
Hide file tree
Showing 281 changed files with 1,025 additions and 224 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ resources/
.RData
.Ruserdata
*.key
teach-shiny-attendees.csv
rsconnect/
rsconnect/
sample-curricula/
attendee-info/
16 changes: 0 additions & 16 deletions content/days/day1/_index.Rmarkdown

This file was deleted.

16 changes: 0 additions & 16 deletions content/days/day1/_index.markdown

This file was deleted.

63 changes: 0 additions & 63 deletions content/days/day2/_index.Rmarkdown

This file was deleted.

70 changes: 0 additions & 70 deletions content/days/day2/_index.markdown

This file was deleted.

10 changes: 0 additions & 10 deletions content/post/_index.md

This file was deleted.

Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added materials/02-outlining/02-outlining.pdf
Binary file not shown.
Binary file added materials/03-scaffolding/03-scaffolding.pdf
Binary file not shown.
File renamed without changes.
92 changes: 92 additions & 0 deletions materials/03-scaffolding/movies/_movies_05.R
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)
Loading

0 comments on commit 2714bbb

Please sign in to comment.