Related
When users select a date using the date range input, I want to convert the format of their selected date and then treat it like a character.
I can get my code to work when it's embedded in a larger reactive to filter my dataset, but I can't get it to work as it's own value. Because I need to use this character string across many areas of my app, I'd rather just write the code once as it's own reactiveVal than having to embed it within larger reactives.
Here's the code that fails (I only moved the from_date outside of the larger reactive):
library(shiny)
library(dplyr)
library(tidyr)
library(htmltools)
library(lubridate)
library(DT)
library(stringr)
ui = fluidPage(
useShinyjs(),
useShinydashboard(),
tabsetPanel(
tabPanel("Resource View", fluid = TRUE,
sidebarLayout(
sidebarPanel(
div(id = "inputs",
dateRangeInput(
inputId = "date_filter",
label = "Filter by Month and Year",
start = today(),
end = (today() + 90),
min = "Apr-2021",
max = NULL,
format = "M-yyyy",
startview = "month",
weekstart = 0,
language = "en",
separator = " to ",
width = NULL,
autoclose = TRUE
),
br()),
),
mainPanel(
DT::DTOutput("resource_table"),
)
)
)
)
)
server = function(input, output, session) {
from_date <- reactiveVal({ tibble(date = as.character(input$date_filter[1]))
from_date <- from_date %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
from_date <- parse_character(from_date$month_year)
})
select_values <- reactive({
data <- tibble(employee = c("Justin", "Corey","Sibley", "Justin", "Corey","Sibley", "Lisa", "NA"),
education = c("graudate", "student", "student", "graudate", "student", "student", "nurse", "doctor"),
fte_max_capacity = c(1, 2, 3, 1, 2, 3, 4, 5),
project = c("big", "medium", "small", "medium", "small", "small", "medium", "medium"),
aug_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
sep_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
oct_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
nov_2021 = c(1, 1, 1, 1, 1, 1, 2, 5))
to_date <- tibble(date = as.character(input$date_filter[2]))
to_date <- to_date %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
to_date <- parse_character(to_date$month_year)
data %>%
dplyr::select(employee, education, fte_max_capacity, project,
from_date():to_date)
})
output$resource_table <- renderDT({
select_values()
})
}
shinyApp(ui = ui, server = server)
And here's the code working perfectly when the from_date is embeded in the reactive for select_values().
library(shiny)
library(plotly)
library(shinyjs)
library(shinydashboard)
library(shinyWidgets)
library(dplyr)
library(tidyr)
library(htmltools)
library(lubridate)
library(DT)
library(janitor)
library(readxl)
library(stringr)
ui = fluidPage(
useShinyjs(),
useShinydashboard(),
tabsetPanel(
tabPanel("Resource View", fluid = TRUE,
sidebarLayout(
sidebarPanel(
div(id = "inputs",
dateRangeInput(
inputId = "date_filter",
label = "Filter by Month and Year",
start = today(),
end = (today() + 90),
min = "Apr-2021",
max = NULL,
format = "M-yyyy",
startview = "month",
weekstart = 0,
language = "en",
separator = " to ",
width = NULL,
autoclose = TRUE
),
br()),
),
mainPanel(
DT::DTOutput("resource_table"),
)
)
)
)
)
server = function(input, output, session) {
select_values <- reactive({
data <- tibble(employee = c("Justin", "Corey","Sibley", "Justin", "Corey","Sibley", "Lisa", "NA"),
education = c("graudate", "student", "student", "graudate", "student", "student", "nurse", "doctor"),
fte_max_capacity = c(1, 2, 3, 1, 2, 3, 4, 5),
project = c("big", "medium", "small", "medium", "small", "small", "medium", "medium"),
aug_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
sep_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
oct_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
nov_2021 = c(1, 1, 1, 1, 1, 1, 2, 5))
from_date <- tibble(date = as.character(input$date_filter[1]))
from_date <- from_date %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
from_date <- parse_character(from_date$month_year)
to_date <- tibble(date = as.character(input$date_filter[2]))
to_date <- to_date %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
to_date <- parse_character(to_date$month_year)
data %>%
dplyr::select(employee, education, fte_max_capacity, project,
from_date:to_date)
})
output$resource_table <- renderDT({
select_values()
})
}
shinyApp(ui = ui, server = server)
In the answer, I'd really appreciate if you could also explain why your solution works and why my original attempt failed. Thank you!
Edit: Tried clarifying from_date by using variable names, but the app still crashes
from_date <- reactiveVal({
start_date <- tibble(date = as.character(input$date_filter[1]))
date1 <- start_date %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
date1 <- parse_character(date1$month_year)
})
You should be able to do from_date in one reactive.
from_date <- reactive({
fdate1 <- tibble(date = as.character(input$date_filter[1]))
fdate2 <- fdate1 %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
fdate <- parse_character(fdate2$month_year)
fdate
})
Same goes for to_date.
Got it! So in line with the comment from #MrFlick, R was getting confused by trying to do so many things in one reactive. When I split each of those 3 segments into it's own reactive, I was able to make it work. If anyone knows a tighter way to get to the same end point, happy to look at other options:
library(shiny)
library(dplyr)
library(tidyr)
library(htmltools)
library(lubridate)
library(DT)
library(stringr)
ui = fluidPage(
useShinyjs(),
useShinydashboard(),
tabsetPanel(
tabPanel("Resource View", fluid = TRUE,
sidebarLayout(
sidebarPanel(
div(id = "inputs",
dateRangeInput(
inputId = "date_filter",
label = "Filter by Month and Year",
start = today(),
end = (today() + 90),
min = "Apr-2021",
max = NULL,
format = "M-yyyy",
startview = "month",
weekstart = 0,
language = "en",
separator = " to ",
width = NULL,
autoclose = TRUE
),
br()),
),
mainPanel(
DT::DTOutput("resource_table"),
)
)
)
)
)
server = function(input, output, session) {
from_date_unclean <- reactive({
tibble(date = as.character(input$date_filter[1]))
})
from_date_midway <- reactive({
from_date_unclean() %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
})
from_date <- reactive({
parse_character(from_date_midway()$month_year)
})
to_date_unclean <- reactive({
tibble(date = as.character(input$date_filter[2]))
})
to_date_midway <- reactive({
to_date_unclean() %>%
mutate(date = str_remove_all(date, "-..$")) %>%
separate(date, into = c("year", "month"), sep = "-") %>%
mutate(month = case_when(
month == "01" ~ "jan",
month == "02" ~ "feb",
month == "03" ~ "mar",
month == "04" ~ "apr",
month == "05" ~ "may",
month == "06" ~ "jun",
month == "07" ~ "jul",
month == "08" ~ "aug",
month == "09" ~ "sep",
month == "10" ~ "oct",
month == "11" ~ "nov",
month == "12" ~ "dec",
TRUE~ "ERROR"
)) %>%
unite("month_year", c(month, year), sep = "_")
})
to_date <- reactive({
parse_character(to_date_midway()$month_year)
})
select_values <- reactive({
data <- tibble(employee = c("Justin", "Corey","Sibley", "Justin", "Corey","Sibley", "Lisa", "NA"),
education = c("graudate", "student", "student", "graudate", "student", "student", "nurse", "doctor"),
fte_max_capacity = c(1, 2, 3, 1, 2, 3, 4, 5),
project = c("big", "medium", "small", "medium", "small", "small", "medium", "medium"),
aug_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
sep_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
oct_2021 = c(1, 1, 1, 1, 1, 1, 2, 5),
nov_2021 = c(1, 1, 1, 1, 1, 1, 2, 5))
data %>%
dplyr::select(employee, education, fte_max_capacity, project,
from_date():to_date())
})
output$resource_table <- renderDT({
select_values()
})
}
shinyApp(ui = ui, server = server)
I'm trying to create a boxplot based on timeseries data for multiple years. I want to group observations from multiple years by a variable "DAP" (similar to day of year 0-365), order them by day from November to March but only display the Month on the X-Axis.
I can create a custom order and X-Axis by creating a factor with each month, that works
level_order <- c('November', 'December', 'January', 'February', 'March')
plot <- ggplot(data = df, aes(y = y, x = factor(Month,level = level_order), group=DAP)) +
geom_boxplot(fill="grey85", width = 2.0) +
scale_x_discrete(limits = level_order)
plot
Now I'm stuck making the alignment on the X-Axis according to the days of the month. For example the first datapoint from November 26th needs to more right, closer to December.
Changing the X-Axis to "Date" creates monthly labels for each year and also removed the grouping.
plot <- ggplot(data = df, aes(y = y, x = Date, group=DAP)) +
geom_boxplot(fill="grey85")
plot + scale_x_date(date_breaks = "1 month", date_labels = "%B")
Setting the X-Axis to "DAP" instead of date gives me the correct order and spacing , but I need to display month on the X-Axis. How can I combine this last graph with the X-Axis labeling of graph 1?
plot <- ggplot(data = df, aes(y = y, x = DAP, group=DAP)) +
geom_boxplot(fill="grey85")
plot
and here a sample of the dataset
DAP Date Month y
1 47 2010-11-26 November 0.6872708
21 116 2011-02-03 February 0.7643213
41 68 2011-12-17 December 0.7021531
61 137 2012-02-24 February 0.7178306
81 92 2013-01-10 January 0.7330749
101 44 2013-11-23 November 0.6610618
121 113 2014-01-31 January 0.7961012
141 68 2014-12-17 December 0.7510821
161 137 2015-02-24 February 0.7799938
181 92 2016-01-10 January 0.6861423
201 47 2016-11-26 November 0.7155526
221 116 2017-02-03 February 0.7397810
241 72 2017-12-21 December 0.7259670
261 144 2018-03-03 March 0.6725775
281 106 2019-01-24 January 0.7637322
301 65 2019-12-14 December 0.7184616
321 134 2020-02-21 February 0.6760159
The following approach uses tidyverse. The date is separated into year-month-day and those newly created columns are made numeric. In the ggplot part position_dodge2(preserve = "single") is used which keeps the boxwidth the same. scale_x_discrete helps to redefine x-axis breaks and tick labels. width = 1 controls the distance between the boxes.
library(tidyverse)
df <- tibble::tribble(
~DAP, ~Date, ~Month, ~y,
47, "2010-11-26", "November", 0.6872708,
116, "2011-02-03", "February", 0.7643213,
68, "2011-12-17", "December", 0.7021531,
137, "2012-02-24", "February", 0.7178306,
92, "2013-01-10", "January", 0.7330749,
44, "2013-11-23", "November", 0.6610618,
113, "2014-01-31", "January", 0.7961012,
68, "2014-12-17", "December", 0.7510821,
137, "2015-02-24", "February", 0.7799938,
92, "2016-01-10", "January", 0.6861423,
47, "2016-11-26", "November", 0.7155526,
116, "2017-02-03", "February", 0.7397810,
72, "2017-12-21", "December", 0.7259670,
144, "2018-03-03", "March", 0.6725775,
106, "2019-01-24", "January", 0.7637322,
65, "2019-12-14", "December", 0.7184616,
134, "2020-02-21", "February", 0.6760159
)
df$Date <- as.Date(df$Date)
df %>%
separate(Date, sep = "-", into = c("year", "month", "day")) %>%
mutate_at(vars("year":"day"), as.numeric) %>%
select(-c(year, Month)) %>%
ggplot(aes(
x = factor(month, level = c(11, 12, 1, 2, 3)), y = y,
group = DAP, color = factor(month)
)) +
geom_boxplot(width = 1, lwd = 0.2, position = position_dodge2(preserve = "single")) +
scale_x_discrete(
breaks = c(11, 12, 1, 2, 3),
labels = c("November", "December", "January", "February", "March")
) +
labs(x = "") +
theme(legend.position = "none")
Try this. To get the right order, spacing and labels I make a new date. As year seems to be not relevant I set the year for obs November and December to 2019,
and for the other obs to 2020.
df <- structure(list(DAP = c(
47L, 116L, 68L, 137L, 92L, 44L, 113L,
68L, 137L, 92L, 47L, 116L, 72L, 144L, 106L, 65L, 134L
), Date = c(
"2010-11-26",
"2011-02-03", "2011-12-17", "2012-02-24", "2013-01-10", "2013-11-23",
"2014-01-31", "2014-12-17", "2015-02-24", "2016-01-10", "2016-11-26",
"2017-02-03", "2017-12-21", "2018-03-03", "2019-01-24", "2019-12-14",
"2020-02-21"
), Month = c(
"November", "February", "December",
"February", "January", "November", "January", "December", "February",
"January", "November", "February", "December", "March", "January",
"December", "February"
), y = c(
0.6872708, 0.7643213, 0.7021531,
0.7178306, 0.7330749, 0.6610618, 0.7961012, 0.7510821, 0.7799938,
0.6861423, 0.7155526, 0.739781, 0.725967, 0.6725775, 0.7637322,
0.7184616, 0.6760159
)), row.names = c(NA, -17L), class = "data.frame")
library(ggplot2)
# Make a new Date to get the correct order as with DAP.
# Set year for obs November and Decemeber to 2019,
# for other Obs to 2020,
df$Date1 <- gsub("20\\d{2}-(1\\d{1})", "2019-\\1", df$Date)
df$Date1 <- gsub("20\\d{2}-(0\\d{1})", "2020-\\1", df$Date1)
df$Date1 <- as.Date(df$Date1)
# use new date gives correcr order, spacing and labels
# Also adjusted limits
plot <- ggplot(data = df, aes(y = y, x = Date1, group = DAP)) +
geom_boxplot(fill = "grey85")
plot +
scale_x_date(date_breaks = "1 month", date_labels = "%B", limits = c(as.Date("2019-11-01"), as.Date("2020-03-31")))
Can you help me make the following bar chart in R? I have some simplified dummy data that i am using to recreate, and then my plan is to manipulate the data in the same way. No need to do the abline. The most important parts are the waterfall aspect.
ï..labels value
1 start 100
2 january 120
3 febuary 140
4 march 160
5 april 180
6 may 130
7 june 140
8 july 170
9 august 160
10 september 180
11 october 190
12 november 210
13 december 200
14 end 200
This gets you the waterfall effect:
library(tidyverse)
df <-
tibble::tribble(
~month, ~month_name, ~value,
1, "start", 100,
2, "january", 120,
3, "febuary", 140,
4, "march", 160,
5, "april", 180,
6, "may", 130,
7, "june", 140,
8, "july", 170,
9, "august", 160,
10, "september", 180,
11, "october", 190,
12, "november", 210,
13, "december", 200,
14, "end", 200
) %>%
mutate(
type = case_when(
month == min(month) ~ "Initial",
month == max(month) ~ "Final",
value > lag(value) ~ "Increase",
TRUE ~ "Decrease"
),
finish = value,
start = if_else(month == max(month), 0, replace_na(lag(value), 0))
)
df %>%
ggplot(aes(xmin = month - 0.3, xmax = month + 0.3, ymin = start, ymax = finish, fill = type)) +
geom_rect() +
scale_x_continuous(
breaks = 1:14,
labels = df %>% select(month_name) %>% pull()
) +
theme(
axis.text.x = element_text(angle = 45, hjust = 1),
legend.position = "none"
)
You should be able to take care of the formatting and colors from here ;)
I've been around the forums looking for a solution to my issue but can't seem to find anything. Derivatives of my question and their answer haven't really helped either. My data has four columns, one for Year and one for Month). I've been wanting to plot the data all in one graph without using any facets for years in ggplot. This is what I've been struggling with so far with:
df<-data.frame(Month = rep(c("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October",
"November", "February", "March"),each = 20),
Year = rep(c("2018", "2019"), times = c(220, 40)),
Type = rep(c("C", "T"), 260),
Value = runif(260, min = 10, max = 55))
df$Month<-ordered(df$Month, month.name)
df$Year<-ordered(df$Year)
ggplot(df) +
geom_boxplot(aes(x = Month, y = Value, fill = Type)) +
facet_wrap(~Year)
I'd ideally like to manage this using dplyr and lubridate. Any help would be appreciated!
One option would be to make a true date value, then you can use the date axis formatter. Something like this is a rough start
ggplot(df) +
geom_boxplot(aes(x = lubridate::mdy(paste(Month, 1, Year)), y = Value, fill = Type, group=lubridate::mdy(paste(Month, 1, Year)))) +
scale_x_date(breaks="month", date_labels = "%m")
Do you mean this?
df<-data.frame(Month = rep(c("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October",
"November", "February", "March"),each = 20),
Year = rep(c("2018", "2019"), times = c(220, 40)),
Type = rep(c("C", "T"), 260),
Value = runif(260, min = 10, max = 55))
df$Month <- factor(df$Month,levels=c("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October",
"November", "Dicember"), ordered = T)
df$Month<-ordered(df$Month)
df$Year<-ordered(df$Year)
df$Year_Month <- paste0(df$Month, " ", df$Year)
df$Year_Month <- factor(df$Year_Month, levels = unique(df$Year_Month))
ggplot(df) +
geom_boxplot(aes(x = Year_Month, y = Value, fill = Type))
Here is my code. I am trying to make an rshiny page to show the mean symptoms in the past 30 days vesus the state based off of slider position (1 to 12 - for month). I know it is a little sloppy but I almost have it. I can get a graph that changes the title based off of the month on the slider but the graph just lists all of the data and not by month. Any help would be great.
`asthma = read.csv("AsthmaChild.Ozone.2006_2007.Sample.csv")
state.month = asthma[,-3:-10]
state.month = state.month[,-4]
state.month = aggregate(state.month$Symptoms.Past30D ~ state.month$STATE +
state.month$Month, state.month, mean)
colnames(state.month) = c("STATE", "Month", "Symptoms.Past30D")
sd = asthma[,-3:-10]
sd = sd[,-4]
sd = aggregate(sd$Symptoms.Past30D ~ sd$STATE + sd$Month, sd, function(x)
sd = sd(x))
colnames(sd) = c("STATE", "Month", "sd")
merged = merge(state.month,sd, by=c("STATE", "Month"))
df = count(asthma, "STATE", "Month")
colnames(df) = c("STATE","Freq")
data = merge(df, merged,by=c("STATE"))
data$sem = (data$sd)/(sqrt(data$Freq))
merged = data
merged$ConfUp = (merged$Symptoms.Past30D) + (merged$sem)
merged$ConfDown = (merged$Symptoms.Past30D) - (merged$sem)
merged$Month = as.character(merged$Month)
merged$Month = gsub("12", "December", merged$Month)
merged$Month = gsub("11", "November", merged$Month)
merged$Month = gsub("10", "October", merged$Month)
merged$Month = gsub("9", "September", merged$Month)
merged$Month = gsub("8", "August", merged$Month)
merged$Month = gsub("7", "July", merged$Month)
merged$Month = gsub("6", "June", merged$Month)
merged$Month = gsub("5", "May", merged$Month)
merged$Month = gsub("4", "April", merged$Month)
merged$Month = gsub("3", "March", merged$Month)
merged$Month = gsub("2", "February", merged$Month)
merged$Month = gsub("1", "January", merged$Month)
index = c(1:12)
values = c("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December")
ui = fluidPage(
sidebarPanel(
sliderInput("Month", "Month: Jan=1, Dec=12",min = 1, max =
12,step=1,value=1)),
mainPanel(plotOutput("plot")))
server = function(input,output){
sliderInput(inputId="Month",
label="Month: Jan=1, Dec=12",
min = 1,
max = 12,
value=1,
step=1)
mainPanel(plotOutput("plot"))
dat = reactive({
test <- merged[merged$Month %in%
seq(from=min(input$Month),to=max(input$Month),by=1),]
})
output$plot = renderPlot({
ggplot(data=merged, aes(x=Symptoms.Past30D, y = STATE)) +
geom_errorbarh(aes(xmin=ConfUp,xmax=ConfDown), height=1, linetype = 1) +
xlab ("Mean Sympotms.Past30D (SEM)") + ylab ("STATE") +
labs(title=paste(values[match(input$Month, index)]))
})
}
shinyApp(ui, server)`