|
|
@@ -1,43 +1,32 @@ |
|
|
|
library(tidyverse) |
|
|
|
library(plotly) |
|
|
|
|
|
|
|
readRDS("imdb.rds") -> imdb |
|
|
|
|
|
|
|
imdb %>% |
|
|
|
distinct(id, .keep_all = T) %>% |
|
|
|
mutate(title = str_c(seriesTitle, " (", startYear, ")")) %>% |
|
|
|
select(id, title) -> shows |
|
|
|
|
|
|
|
shows$id %>% |
|
|
|
setNames(shows$title) -> shows |
|
|
|
|
|
|
|
ui <- fluidPage( |
|
|
|
inputPanel(width = "20%", height = "100%", |
|
|
|
uiOutput("show_choice") |
|
|
|
h1("GraphTV"), |
|
|
|
selectizeInput("show", "Search show", shows, selected = "tt0944947", width = "600px") |
|
|
|
), |
|
|
|
plotlyOutput("show_graph", width = "100%", height = "800px") |
|
|
|
) |
|
|
|
|
|
|
|
server <- function(input, output, session) |
|
|
|
{ |
|
|
|
imdb <- reactive({ |
|
|
|
readRDS("imdb.rds") |
|
|
|
}) |
|
|
|
|
|
|
|
shows <- reactive({ |
|
|
|
req(imdb()) |
|
|
|
|
|
|
|
imdb() %>% |
|
|
|
distinct(id, .keep_all = T) %>% |
|
|
|
mutate(title = str_c(seriesTitle, " (", startYear, ")")) %>% |
|
|
|
select(id, title) -> shows |
|
|
|
|
|
|
|
shows$id %>% |
|
|
|
setNames(shows$title) |
|
|
|
}) |
|
|
|
|
|
|
|
output$show_choice <- renderUI({ |
|
|
|
req(shows()) |
|
|
|
|
|
|
|
selectizeInput("show", "Please choose…", shows(), selected = "") |
|
|
|
}) |
|
|
|
|
|
|
|
output$show_graph <- renderPlotly({ |
|
|
|
req(input$show) |
|
|
|
|
|
|
|
show_id <- input$show |
|
|
|
|
|
|
|
imdb() %>% |
|
|
|
imdb %>% |
|
|
|
filter(id == show_id) %>% |
|
|
|
collect %>% |
|
|
|
mutate_at(vars(season, episode, averageRating, numVotes), as.numeric) %>% |
|
|
|