-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathapp_07.R
63 lines (54 loc) · 1.24 KB
/
app_07.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
library(shiny)
library(ggplot2)
library(dplyr)
library(DT)
players <- read.csv("data/nba2018.csv")
ui <- fluidPage(
titlePanel("NBA 2018/19 Player Stats"),
sidebarLayout(
sidebarPanel(
"Exploring all player stats from the NBA 2018/19 season",
h3("Filters"),
sliderInput(
inputId = "VORP",
label = "Player VORP rating at least",
min = -3, max = 10,
value = 0
),
selectInput(
"Team", "Team",
unique(players$Team),
selected = "Golden State Warriors"
)
),
mainPanel(
strong(
"There are",
textOutput("num_players", inline = TRUE),
"players in the dataset"
),
plotOutput("nba_plot"),
DTOutput("players_data")
)
)
)
server <- function(input, output, session) {
filtered_data <- reactive({
players %>%
filter(VORP >= input$VORP,
Team %in% input$Team)
})
output$players_data <- renderDT({
filtered_data()
})
output$num_players <- renderText({
nrow(filtered_data())
})
output$nba_plot <- renderPlot({
ggplot(filtered_data(), aes(Salary)) +
geom_histogram() +
theme_classic() +
scale_x_log10(labels = scales::comma)
})
}
shinyApp(ui, server)