I am making a shiny app to generate stock price plots. I want to generate plots given a certain date range, but I get the error "argument 1 is not a vector" whenever I try to adjust the dates. If I remove the "daterangeinput" part from my app, everything works fine. I have attached my code + data.
Run the section below to get the data.
library(tidyquant)
library(tidyverse)
library(shiny)
library(shinyWidgets)
library(shinythemes)
library(plotly)
sp500_names <- tq_index("SP500") %>%
slice_head(n = 10) %>%
select(symbol, company)
tickers <- sp500_names[,1]
prices <- tq_get(tickers,
get = "stock.prices",
from = today() - months(24),
to = today(),
complete_cases = F) %>%
select(symbol, date, close)
Code for shiny app:
ui <- fluidPage(
# Title
titlePanel("Stock Price Visualization and Forecasting"),
# Sidebar
sidebarLayout(
sidebarPanel(width = 3,
pickerInput(
inputId = "stocks",
label = h4("Pick a stock"),
choices = tickers$symbol,
selected = tickers,
options = list(`actions-box` = TRUE),
multiple = T),
# Date input
dateRangeInput("daterange", "Pick a Time Period",
# value = today(),
min = today() - months(23),
max = today())),
# Plot results
mainPanel(
plotlyOutput("plot",height=600)
)
)
)
server <- function(input, output, session) {
# Server logic based on user inputs
observeEvent(input$stocks,{
prices <- prices %>%
dplyr::filter(symbol %in% input$stocks) %>%
filter(date > input$daterange[1] & date <= input$daterange[2])
# Create plot
output$plot <- renderPlotly({
print(
ggplotly(prices %>%
ggplot(aes(date, close, color = symbol)) +
geom_line(size = 1, alpha = 0.9)+
theme_minimal(base_size=16) +
theme(axis.title=element_blank(),
plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill="grey"),
panel.grid = element_blank(),
legend.text = element_text(colour="black"))
)
)
})
})
}
shinyApp(ui, server)
The issue is that you have not set any start and end dates for the date range and your apps does not take care of that. Hence an easy fix would be to simply set a default start and end date. Additionally IMHO I don't see any reason for an observeEvent. Instead I would suggest to use a reactive to filter your data based on user inputs, which could then be used for plotting:
library(tidyquant)
library(tidyverse)
library(shiny)
library(shinyWidgets)
library(shinythemes)
library(plotly)
ui <- fluidPage(
# Title
titlePanel("Stock Price Visualization and Forecasting"),
# Sidebar
sidebarLayout(
sidebarPanel(
width = 3,
pickerInput(
inputId = "stocks",
label = h4("Pick a stock"),
choices = tickers$symbol,
selected = tickers,
options = list(`actions-box` = TRUE),
multiple = T
),
# Date input
dateRangeInput("daterange", "Pick a Time Period",
# value = today(),
start = min(prices$date),
end = today(),
min = min(prices$date),
max = today()
)
),
# Plot results
mainPanel(
plotlyOutput("plot", height = 600)
)
)
)
server <- function(input, output, session) {
prices_filtered <- reactive({
req(input$stocks)
prices %>%
dplyr::filter(symbol %in% input$stocks) %>%
filter(date > input$daterange[1] & date <= input$daterange[2])
})
output$plot <- renderPlotly({
req(input$stocks)
g <- ggplot(prices_filtered(), aes(date, close, color = symbol)) +
geom_line(size = 1, alpha = 0.9) +
theme_minimal(base_size = 16) +
theme(
axis.title = element_blank(),
plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill = "grey"),
panel.grid = element_blank(),
legend.text = element_text(colour = "black")
)
ggplotly(g)
})
}
shinyApp(ui, server)
Related
The data is from here. I selected the "Get table as CSV (for Excel)" option from "Share & Export". I highlighted all the resulting table text, and copied to excel. I then did "Text to columns" and split the data by the comma delimiters. I then saved the file as a .csv extension. My goal is to create an app with sliders for minutes and games played with a check box for teams. I want plotly graphs with pop ups. My code is below.
library(shiny)
library(ggplot2)
library(dplyr)
library(plotly)
library(tidyverse)
Player_Stats<-read.csv("2021-2022 Indiv Per Game Stats.csv")
colnames(Player_Stats)[11]<-"FG%"
colnames(Player_Stats)[14]<-"ThreeP%"
colnames(Player_Stats)[17]<-"TwoP%"
colnames(Player_Stats)[18]<-"eFG%"
colnames(Player_Stats)[21]<-"FT%"
colnames(Player_Stats)
ui<-fluidPage(
titlePanel("Player Stats"),
sidebarLayout(
sidebarPanel(
sliderInput("input1",
"Minutes",
min=0,
max = max(MP),
value = 0),
sliderInput("Input2",
"Games Played",
min = 0,
max = 82,
value = 0),
checkboxGroupInput(inputId = "tm_input",
label = "Team",
choices = unique(Player_Stats$Tm),
selected = unique(Player_Stats$Tm))
),
mainPanel(
plotOutput("plot1"),
plotOutput("plot2"),
dataTableOutput("Player_StatsTable")
)
)
)
server<-function(input, output){
output$plot1<-renderPlotly({
Player_Stats.subset() %>% ggplotly(
ggplot(aes(x=PTS, y=`ThreeP%`,color=Tm,
text=paste("Player:",Player, "PPG:",PTS, "3P%:", `ThreeP%`*100, "Team:",Tm)))+
geom_point()+
geom_smooth()+
xlab("Points per Game")+
ylab("Three Point %")+
ggtitle("PPG and 3P% by Player")+
theme(plot.title = element_text(hjust = 0.5))
)
})
output$plot2<-renderPlotly({
Player_Stats.subset() %>% ggplotly(
ggplot(aes(x=PTS, y=`TwoP%`,color=Tm,
text=paste("Player:",Player, "PPG:",PTS, "2P%:", `2P%`*100, "Team:",Tm)))+
geom_point()+
geom_smooth()+
xlab("Points per Game")+
ylab("Two Point %")+
ggtitle("PPG and 2P% by Player")+
theme(plot.title = element_text(hjust = 0.5))
)
})
Player_Stats.subset=reactive({
Player_Stats %>%
dplyr::filter(Tm %in% input$Tm_,.preserve = TRUE) %>%
dplyr::filter(MP>=input$input1) %>%
dplyr::filter(G>=input$input2)
})
output$Player_StatsTable<-renderDataTable({
Player_Stats.subset
})
}
shinyApp(ui=ui,server=server)
I have my shiny app in AWS ubuntu server attached with mysql database, my app doesnot work sometimes when number of database connection exceeded(16 new connections). I tried several ways from various sources in internet but not able to get the required solution.
Furthure i am also getting warning you have leaked pool object . I am attaching the sample code.
library("shiny")
library("shinydashboard")
library("pool")
library(ggplot2)
library("DBI")
library(plotly)
pool <- dbPool(drv = RMySQL::MySQL(),dbname = "db",host = "database.cw5east-2.rds.amazonaws.com",username = "host",password = "host", port = 3306)
mychoices = dbGetQuery(pool,"select available_scenario from scenario_name;")
ui <- (fluidPage(
titlePanel("Demonstration of renderUI in shiny - Dymanically creating the tabs based on user inputs"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = 'n', "available scenarios", choices = mychoices, multiple = TRUE),
verbatimTextOutput("selected")
),
mainPanel(
plotOutput('Cost'),
uiOutput('tabs')
)
)
))
server <- (function(input,output,session){
output$tabs = renderUI({
par(mfrow = c(2, 2))
if(!is.null(input$n)){
x <- input$n
y <- length(x)
z <- dbGetQuery(pool,paste0("select scenario_key from scenario_name where available_scenario = '",x[y],"'"))
frame <- dbGetQuery(pool,paste0("select x,price from plot1 where scenario_key ='",z,"'"))
frame1 <- dbGetQuery(pool,paste0("select obj,runs from plot2 where scenario_key ='",z,"'"))
frame2 <- dbGetQuery(pool,paste0("select V1,V2,V3 from tableee where scenario_key ='",z,"'"))
runs <- dbGetQuery(pool,paste0(" select count(*) from plot2 where scenario_key ='",z,"'"))
b<-dbGetQuery(pool, paste0("select scenario_key from scenario_name where available_scenario = '",input$n,"'"))
Tabs <- lapply(paste("Scenario name:", input$n, sep=" "), tabPanel,
renderPlotly({
ggplot(frame, aes(x=x,y=price,fill=price)) + # basic graphical object
geom_col(width = 0.3)+
#geom_bar(position = 'dodge',stat = "identity")+ # first layer
xlab(NULL)+ylab("Price in USD")+
geom_text(aes(label=price),size=5,position=position_dodge(width=0.9), vjust=-0.25)+
theme_minimal()+
theme(axis.text = element_text(size = 12),
axis.title = element_text(size=16),
axis.text.y =element_text(angle = 90,hjust = 1))
}),
renderPlotly({
ggplot(frame1,aes(x=runs,y=obj))+
geom_col(width=0.3,fill='orangered')+
geom_hline(aes(yintercept=mean(obj,na.rm = T),color="Mean"),linetype='dashed',size=1)+
scale_color_manual(values = "blue")+
labs(x= 'Day Number',y='Reveneue in USD',color=NULL)+
theme_minimal()+theme(axis.text = element_text(size = 12),
axis.title = element_text(size=16),
axis.text.y= element_text(angle = 90,hjust = 1) )
}),
DT::renderDataTable({
frame2
},colnames=c('Day','Total Wt(kg)','Total Pcs','Revenue($)')
)
)
do.call(tabsetPanel, Tabs)}
})
})
shinyApp(ui, server)
I am trying to build a shiny app to show COVID-19 cases for the 10 worst affected countries with refreshes daily from the ECDC website. I want to be able to limit cases and deaths using slider inputs, and select date periods with date inputs, (all already added).
The code is below, but when I run the app I get a blank plot, the axis are displaying correctly but I can't get the points to appear. This should be able to run on any computer as the code just downloads the data set from the ECDC page.
Any solutions?
library(shiny)
library(readxl)
library(dplyr)
library(httr)
library(ggplot2)
library(plotly)
url <- paste("https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-",format(Sys.time(), "%Y-%m-%d"), ".xlsx", sep = "")
GET(url, authenticate(":", ":", type="ntlm"), write_disk(tf <- tempfile(fileext = ".xlsx")))
data <- read_excel(tf)
include<-c("United_Kingdom","Italy","France","China",
"United_States_of_America","Spain","Germany",
"Iran","South_Korea","Switzerland")
ui <- fluidPage(
titlePanel("COVID-19 Daily Confirmed Cases & Deaths"),
sidebarLayout(
sidebarPanel(
checkboxGroupInput("Country", "Select Country", selected = NULL, inline = FALSE,
width = NULL),
dateRangeInput("DateRep","Select Date Range", start = "2019-12-31", end = NULL),
sliderInput("Cases","Select Cases Range", min = 1, max = 20000, value = NULL),
sliderInput("Deaths", "Select Death Range", min = 1, max = 10000, value = 100),
submitButton("Refresh")
),
mainPanel(
plotOutput("plot")
)
)
)
server <- function(input, output) {
output$plot <- renderPlot({
include<-input$Country
plot_data<-filter(data, `Countries and territories` %in% include)%>%
filter(between(input$Cases))
plot_data%>% ggplot(aes(x=input$DateRep, y=input$Cases, size =input$Deaths, color = input$Country)) +
geom_point(alpha=0.5) +
theme_light()
})
}
shinyApp(ui = ui, server = server)
I think it would be better to define and filter the data you want to plot in a reactive expression outside of renderPlot. It will allow you to re-use these data more easily and it is easier (from my point of view) to use ggplot without inputs directly in it.
I include as.Date(DateRep) >= input$DateRep[1] & as.Date(DateRep) <= input$DateRep[2]) in filter to select the interval between the two chosen dates. Since the column DateRep has a POSIXct format, you need to use as.Date on it to convert it to the format dateRangeInput produces.
Here's the result:
library(shiny)
library(readxl)
library(dplyr)
library(httr)
library(ggplot2)
library(plotly)
url <- paste("https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-",format(Sys.time(), "%Y-%m-%d"), ".xlsx", sep = "")
GET(url, authenticate(":", ":", type="ntlm"), write_disk(tf <- tempfile(fileext = ".xlsx")))
data <- read_excel(tf)
include<-c("United_Kingdom","Italy","France","China",
"United_States_of_America","Spain","Germany",
"Iran","South_Korea","Switzerland")
ui <- fluidPage(
titlePanel("COVID-19 Daily Confirmed Cases & Deaths"),
sidebarLayout(
sidebarPanel(
checkboxGroupInput("Country", "Select Country", choices = include, selected = "France"),
dateRangeInput("DateRep","Select Date Range", start = "2019-12-31", end = NULL),
sliderInput("Cases","Select Cases Range", min = 1, max = 20000, value = NULL),
sliderInput("Deaths", "Select Death Range", min = 1, max = 10000, value = 100),
submitButton("Refresh")
),
mainPanel(
plotOutput("plot")
)
)
)
server <- function(input, output) {
plot_data <- reactive({
filter(data, `Countries and territories` %in% input$Country
& as.Date(DateRep) >= input$DateRep[1]
& as.Date(DateRep) <= input$DateRep[2]) %>%
filter(between(Cases, 1, input$Cases))
})
output$plot <- renderPlot({
plot_data() %>%
ggplot(aes(x = as.Date(DateRep), y= Cases, size = Deaths, color = `Countries and territories`)) +
geom_point(alpha=0.5) +
theme_light()
})
}
shinyApp(ui = ui, server = server)
I started to fix this, but ran out of time... so here's what I did, maybe you can complete it...
library(shiny)
library(readxl)
library(dplyr)
library(httr)
library(ggplot2)
library(plotly)
url <- paste("https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-",format(Sys.time(), "%Y-%m-%d"), ".xlsx", sep = "")
GET(url, authenticate(":", ":", type="ntlm"), write_disk(tf <- tempfile(fileext = ".xlsx")))
data <- read_excel(tf)
ui <- fluidPage(
titlePanel("COVID-19 Daily Confirmed Cases & Deaths"),
sidebarLayout(
sidebarPanel(
uiOutput("country_checkbox"),
dateRangeInput("DateRep","Select Date Range", start = "2019-12-31", end = NULL),
sliderInput("Cases","Select Cases Range", min = 1, max = 20000, value = NULL),
sliderInput("Deaths", "Select Death Range", min = 1, max = 10000, value = 100)
#submitButton("Refresh")
),
mainPanel(
plotOutput("plot")
)
)
)
server <- function(input, output) {
output$country_checkbox <- renderUI({
countries <- unique(data.frame(data)[, "Countries.and.territories"])
checkboxGroupInput("country", "Select Country",
choices = countries,
selected = NULL, inline = FALSE,
width = NULL)
})
output$plot <- renderPlot({
include<-input$country
plot_data<-filter(data, `Countries and territories` %in% include)%>%
filter(between(Cases, 1, input$Cases))
plot_data%>% ggplot(aes(x=DateRep, y=Cases, size =Deaths, color = `Countries and territories`)) +
geom_point(alpha=0.5) +
theme_light()
})
}
shinyApp(ui = ui, server = server)
My ggplotly plot (see Tab 3 in server.R) does not work when used in my Shiny app. However, when I generate the plot by itself in RStudio, it works fine.
This is the bit of code that does not render a plot correctly.
output$facetmap=renderPlotly({
ggplotly(
ggplot(ranksvf(),aes(Rank,input$parameterchoice,fill=Location))+
ggtitle("") +
theme(axis.title.y=element_blank())+
geom_bar(position="dodge",stat="identity")+
facet_wrap(~Tran.Hour.2h.Slot,nrow=2)
)
})
When I say it doesn't render a plot correctly, I mean two things:
1) When I use input$parameterchoice in ggplot, the graph comes out weird. It looks like this. Incorrect Plot
2) When I use the actual name of the input in ggplot instead of input$parameterchoice, the plot comes out fine. However when I mouseover the plot, the values do not show as they should (it is a plotly graph so it should show).
What I find strange is that I use a ggplotly in Tab 2 of my application as well, and it works fine (the mouseover works too).
I feel the problem has something to do with the way I used my reactive functions, though I'm not sure. I've tried to debug for a while, but no luck so far.
This is what my app looks like.
####
#UI#
####
ui=fluidPage(theme = shinytheme("paper"),
titlePanel("Visualising Site-Specific Indicators: XYZ University"),
#img(src='xyz.jpg', align = "left"),
tabsetPanel(
#TAB 1
tabPanel(type="pills","Macro-View of Locations",
fluidRow(
column(width = 4,
wellPanel(
selectInput("size",
label="Select Parameter for Rectangle Size",
choices=names(details)[2:5],selected = "Average Daily Transactions"))),
column(width = 4,
wellPanel(
selectInput("color",
label="Select Parameter for Rectangle Color",
choices=names(details)[2:5],selected = "Unique Products Sold"))
)#Close column
), #Close fluidRow
fluidRow(
plotOutput("plot")),
fluidRow(
dataTableOutput("tab"))
),#Close tabPanel macroview
#TAB 2
tabPanel("Transaction Overiew by Location",
fluidRow(
column(width = 4,
wellPanel(
selectInput("sitechoice",
label="Select a Site",
choices=unique(heatmap_mean$Location),selected = "Horton 1"))
)#Close column
), #Close fluidRow
fluidRow(
plotlyOutput("heatmap")),
fluidRow(
dataTableOutput("tab2"))
),#Close tabPanel transactionoverview
#TAB 3
tabPanel("Parameter Ranking",
fluidRow(
column(width = 4,
wellPanel(
selectInput("parameterchoice",
label="Rank By",
choices=unique(c(names(rankdf_avgtran),names(rankdf_ticket)))[3:4],selected = "Average Transaction Value (USD)"))
),#Close column
column(width=6,
wellPanel(
sliderInput("rankchoice",
label="Number of Ranks Desired",
min=1,
max=10,
value=5))
)#Close column
), #Close fluidRow
fluidRow(
plotlyOutput("facetmap")),
fluidRow(
dataTableOutput("tab3"))
)#Close tabPanel transactionoverview
) #Close tabsetpanel
) #Close UI
########
#SERVER#
########
server=function(input, output,session) {
# TAB 1
sortTable <- reactive({
details[do.call(order, -details[as.character(input$size)]),]
})
output$plot= renderPlot ({
treemap(details,
index=c("Site"),
vSize=input$size,
vColor=input$color,
title="XYZ University: Overview of Site Data",
fontsize.title = 20,
#sortID = paste("-",input$sort,sep=""),
type="value")
})
output$tab <- renderDataTable({
sortTable()
})
#TAB 2
test=reactive({
heatmap_mean %>% filter(Location==input$sitechoice)
})
output$heatmap=renderPlotly({
ggplotly(
ggplot(test(), aes(Day, `Time Slot`)) +
geom_tile(aes(fill = `Average Number of Transactions`),color = "white") +
scale_fill_gradient(low = "lightblue", high = "darkblue") +
ylab("") +
xlab("") +
theme(legend.title = element_text(size = 8),
panel.background = element_blank(),
legend.text = element_text(size = 8),
plot.title = element_text(size=18),
axis.title=element_text(size=22,face="bold"),
axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(fill = ""))
})
output$tab2 <- renderDataTable({
test()
})
#TAB 3
ranks_pen <- reactive({
if(input$parameterchoice=="Average Number of Transactions")
{
showdata=rankdf_avgtran %>%
group_by(Tran.Hour.2h.Slot) %>%
top_n(n = input$rankchoice, wt = `Average Number of Transactions`) %>% #For each time slot, cut off top n values.
mutate(Rank = rank(-`Average Number of Transactions`, ties.method = "first")) #And rank for each of the 'n' sites for each time slot
return(showdata)
}
else
if(input$parameterchoice=="Average Transaction Value (USD)")
{
showdata=rankdf_ticket %>%
group_by(Tran.Hour.2h.Slot) %>%
top_n(n = input$rankchoice, wt = `Average Transaction Value (USD)`) %>% #For each time slot, cut off top 'n' values.
mutate(Rank = rank(-`Average Transaction Value (USD)`, ties.method = "first")) #And rank the 'n' sites for each time slot
return(showdata)
}
})
ranksvf<- reactive({
ranks_pen() %>%
group_by(Tran.Hour.2h.Slot) %>% #Group the columns
arrange(Rank) #Arrange rank from 1 to 'n'
})
output$facetmap=renderPlotly({
ggplotly(
ggplot(ranksvf(),aes(Rank,input$parameterchoice,fill=Location))+
ggtitle("") +
theme(axis.title.y=element_blank())+
geom_bar(position="dodge",stat="identity")+
facet_wrap(~Tran.Hour.2h.Slot,nrow=2)
)
})
output$tab3 <- renderDataTable({
ranksvf()
})
}#Close server
#RUN APP
shinyApp(ui,server)
input$parameterchoice returns a quoted string, however aes only accepts unquoted strings as arguments. Using aes_ instead should resolve the issue
output$facetmap=renderPlotly({
pc <- input$parameterchoice
ggplotly(
ggplot(ranksvf(),aes_(quote(Rank),as.name(pc),fill=quote(Location)))+
ggtitle("") +
theme(axis.title.y=element_blank())+
geom_bar(position="dodge",stat="identity")+
facet_wrap(~Tran.Hour.2h.Slot,nrow=2)
)
})
Try it:
selectInput("parameterchoice",
label="Rank By",
choices=as.list(unique(c(names(rankdf_avgtran),names(rankdf_ticket)))[3:4]),
selected = "Average Transaction Value (USD)")
Implementing this with ggplot2 and shiny by having two input selections for the date ranges and have the plot adjust the x(date values) adjust accordingly, however, I get this error below:
Invalid input: date_trans works with objects of class Date only
How can I resolve this? Here is my code below:
library(shiny)
library(ggplot2)
library(dplyr)
data <- read.csv("C:/Users/user/Documents/R/R-3.3.1/R CODE/MyData2.csv", header = TRUE) # reading .csv
newdata <- as.data.frame(data) # converting csv to DF
newdata$event_date <- as.factor(newdata$event_date)
str(newdata)
ui <- fluidPage(
selectInput("select", label = h3("Select Model"),
choices = list("Toyota Camry", "Nissan Altima")),
dateInput("strtdate", "Select start date:"),
dateInput("enddate", "Select end date:"),
plotOutput("hist")
)
server <- function(input, output) {
output$hist <- renderPlot({
df <- newdata %>% select(event_date,PlatformName,total_events) %>% filter(PlatformName == input$select) %>% group_by(event_date, PlatformName) %>% summarize(total_events = sum(total_events))
gg <- ggplot(df, aes(x= event_date, y = total_events, group =PlatformName)) +
geom_line(aes(color = PlatformName)) +
labs(title="Total Events vs. Time", x="Event Dates", y="Total Events") +
aes(xmin = input$strtdate,
xmax = input$enddate) +
theme(plot.title=element_text(size=20, face="bold", hjust = 0.5),
axis.text.x=element_text(size=10, angle=90,hjust=1,vjust=0.5),
axis.text.y=element_text(size=5),
axis.title.x=element_text(size=10),
axis.title.y=element_text(size=10))
print(gg)
})
}
shinyApp(ui = ui, server = server)
Solved the issue. Just needed to convert the specific date column in a date format.
Via:
newdata$event_date <- as.Date(newdata$event_date)
Thus, new code:
library(shiny)
library(ggplot2)
library(dplyr)
data <- read.csv("C:/Users/user/Documents/R/R-3.3.1/R CODE/MyData2.csv", header = TRUE) # reading .csv
newdata <- as.data.frame(data) # converting csv to DF
newdata$event_date <- as.factor(newdata$event_date) #CODE IMPLEMENTAITON
str(newdata)
ui <- fluidPage(
selectInput("select", label = h3("Select Model"),
choices = list("Toyota Camry", "Nissan Altima")),
dateInput("strtdate", "Select start date:"),
dateInput("enddate", "Select end date:"),
plotOutput("hist")
)
server <- function(input, output) {
output$hist <- renderPlot({
df <- newdata %>% select(event_date,PlatformName,total_events) %>% filter(PlatformName == input$select) %>% group_by(event_date, PlatformName) %>% summarize(total_events = sum(total_events))
gg <- ggplot(df, aes(x= event_date, y = total_events, group =PlatformName)) +
geom_line(aes(color = PlatformName)) +
labs(title="Total Events vs. Time", x="Event Dates", y="Total Events") +
aes(xmin = input$strtdate,
xmax = input$enddate) +
theme(plot.title=element_text(size=20, face="bold", hjust = 0.5),
axis.text.x=element_text(size=10, angle=90,hjust=1,vjust=0.5),
axis.text.y=element_text(size=5),
axis.title.x=element_text(size=10),
axis.title.y=element_text(size=10))
print(gg)
})
}
shinyApp(ui = ui, server = server)