-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabynames_app.R
41 lines (38 loc) · 1.33 KB
/
babynames_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
library(shiny)
library(tidyverse)
library(babynames)
ui <- fluidPage(textInput(inputId = "name",
label = "Name",
value = "",
placeholder = "Your name goes here",
),
selectInput(inputId = "sex",
label = "Sex:",
choices = list(Female = "F",
Male = "M")
),
sliderInput(inputId = "year",
label = "Year Range:",
min = min(babynames$year),
max = max(babynames$year),
value = c(min(babynames$year),
max(babynames$year)),
sep = ""
),
submitButton(text = "Plot"),
plotOutput(outputId = "nameplot"),
)
server <- function(input, output) {
output$nameplot <- renderPlot(
babynames %>%
filter(sex == input$sex,
name == input$name,
) %>%
ggplot(aes(x = year,
y = n)) +
geom_line()+
scale_x_continuous(limits = input$year) +
theme_minimal()
)
}
shinyApp(ui = ui, server = server)