-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
75 lines (67 loc) · 1.82 KB
/
app.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
64
65
66
67
68
69
70
71
72
73
74
75
library(shiny)
library(shinydashboard)
library(bslib)
library(ggplot2)
library(DT)
load("movies.RData")
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
selectInput(
inputId = "y",
label = "Y-axis:",
choices = c("imdb_rating", "imdb_num_votes", "critics_score", "audience_score", "runtime"),
selected = "audience_score"
),
selectInput(
inputId = "x",
label = "X-axis:",
choices = c("imdb_rating", "imdb_num_votes", "critics_score", "audience_score", "runtime"),
selected = "critics_score"
),
sliderInput(
inputId = "slider",
label = "alpha",
min = 10, max = 150,
value = 75
),
checkboxInput(
inputId = "show_data",
label = "Show data table",
value = TRUE
)
),
dashboardBody(
fluidRow(
box(
plotOutput(outputId = "scatterplot")
),
box(
plotOutput(outputId = "densityplot")
),
box(
DT::dataTableOutput(outputId = "moviestable")
)
)
)
)
server <- function(input, output, session) {
output$scatterplot <- renderPlot({
ggplot(data = movies, aes_string(x = input$x, y = input$y)) +
geom_point(alpha = input$slider )
})
output$moviestable <- renderDataTable({
if (input$show_data) {
DT::datatable(
data = movies %>% select(1:7),
options = list(pageLength = 10),
rownames = FALSE
)
}
})
output$densityplot <- renderPlot({
ggplot(data = movies, aes_string(x = input$x)) +
geom_density()
})
}
shinyApp(ui, server)