-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatgpt-quote4-1.R
55 lines (48 loc) · 1.15 KB
/
chatgpt-quote4-1.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
library(shiny)
library(plotly)
library(dplyr)
library(leaflet)
# Load the storms dataset
data(storms)
# Create a UI
ui <- fluidPage(
titlePanel("Storms Dashboard"),
sidebarLayout(
sidebarPanel(
selectInput("year", "Select Year:",
choices = unique(storms$year),
selected = 2000),
),
mainPanel(
tabsetPanel(
tabPanel("Table",
dataTableOutput("table")),
tabPanel("Map",
leafletOutput("map")),
tabPanel("Chart",
plotlyOutput("chart"))
)
)
)
)
# Create a server
server <- function(input, output) {
# Create the table
output$table <- renderDataTable({
storms %>% filter(year == input$year)
})
# Create the map
output$map <- renderLeaflet({
storms %>% filter(year == input$year) %>%
leaflet() %>% addTiles() %>%
addMarkers(~longitude, ~latitude, popup = ~as.character(date))
})
# Create the chart
output$chart <- renderPlotly({
storms %>% filter(year == input$year) %>%
plot_ly(x = ~date, y = ~wind) %>%
add_lines()
})
}
# Run the app
shinyApp(ui = ui, server = server)