Hello I am having an issues with a script I am writing. I know there are multiple problems and I am trying to fix them as the show up. The latest issue, I am having issues with
library(shiny)
library(readxl)
library(plotly)
library(dplyr)
library(ggplot2)
library(forecast)
ndl_data<-read_excel("STE1 Account Work.xlsx")
# convert the Closed column to an actual date so that we can easily select all days in a given year.
ndl_data$Closed <- as.Date(ndl_data$Closed, format = "%d-%m-%Y")
# select everything by year thate is a specific network
df2018 <- ndl_data[which(ndl_data$"Closed" >= "2018-01-01" & ndl_data$"Closed" <= "2018-12-31"),]
df2019 <- ndl_data[which(ndl_data$"Closed" >= "2019-01-01" & ndl_data$"Closed" <= "2019-12-31"),]
df2020 <- ndl_data[which(ndl_data$"Closed" >= "2020-01-01" & ndl_data$"Closed" <= "2020-12-31"),]
df2018c <- ndl_data[which(ndl_data$"Closed" >= "2018-01-01" & ndl_data$"Closed" <= "2018-12-31" & ndl_data$"Network" == "COE"),]
df2018c<-df2018c %>%
group_by("Closed") %>%
mutate("Number"=n())
df2018c<-subset(df2018c, select=c("Closed", "Number"))
dfc2019 <- ndl_data[which(ndl_data$"Closed" >= "2019-01-01" & ndl_data$"Closed" <= "2019-12-31" & ndl_data$"Network" == "COE"),]
df2019c <-dfc2019 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2019c<-subset(df2019c, select=c("Closed", "Number"))
dfc2020 <- ndl_data[which(ndl_data$"Closed" >= "2020-01-01" & ndl_data$"Closed" <= "2020-12-31" & ndl_data$"Network" == "COE"),]
df2020c <-dfc2020 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2020c<-subset(df2020c, select=c("Closed", "Number"))
#___________________________________________________________________________________________________________________________________________
dfs12018 <- ndl_data[which(ndl_data$"Closed" >= "2018-01-01" & ndl_data$"Closed" <= "2018-12-31" & ndl_data$"Network" == "SECNet"),]
df2018s1 <-dfs12018 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2018s1<-subset(df2018s1, select=c("Closed", "Number"))
dfs12019 <- ndl_data[which(ndl_data$"Closed" >= "2019-01-01" & ndl_data$"Closed" <= "2019-12-31" & ndl_data$"Network" == "SECNet"),]
df2019s1 <-dfs12019 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2019s1<-subset(df2019s1, select=c("Closed", "Number"))
dfs12020 <- ndl_data[which(ndl_data$"Closed" >= "2020-01-01" & ndl_data$"Closed" <= "2020-12-31" & ndl_data$"Network" == "SECNet"),]
df2020s1 <-dfs12020 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2020s1<-subset(df2020s1, select=c("Closed", "Number"))
#___________________________________________________________________________________________________________________________________________
dfs22018 <- ndl_data[which(ndl_data$"Closed" >= "2018-01-01" & ndl_data$"Closed" <= "2018-12-31" & ndl_data$"Network" == "SBUNet"),]
df2018s2 <-dfs22018 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2018s2<-subset(df2018s2, select=c("Closed", "Number"))
dfs22019 <- ndl_data[which(ndl_data$"Closed" >= "2019-01-01" & ndl_data$"Closed" <= "2019-12-31" & ndl_data$"Network" == "SBUNet"),]
df2019s2 <-dfs22019 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2019s2<-subset(df2019s2, select=c("Closed", "Number"))
dfs22020 <- ndl_data[which(ndl_data$"Closed" >= "2020-01-01" & ndl_data$"Closed" <= "2020-12-31" & ndl_data$"Network" == "SBUNet"),]
df2020s2 <-dfs22020 %>%
group_by("Closed") %>%
mutate("Number"=n())
df2020s2<-subset(df2020s2, select=c("Closed", "Number"))
#___________________________________________________________________________________________________________________________________________
ui <- fluidPage(
# Application title
titlePanel("NCL User Account Forcasting"),
# Sidebar
sidebarLayout(
sidebarPanel(
selectInput("year", "Year",
list("2020"= "2020","2019"="2019","2018"="2018","2017"="2017")),
numericInput("ahead", "Months to Forecast Ahead:", 12),
submitButton("Update View"),
),
# Show a plot of the generated distribution
mainPanel(
h3(textOutput("caption")),
tabsetPanel(
tabPanel(
splitLayout(cellWidths=c("50%","50%"), plotOutput("fitt"),plotOutput("etsForecasttPlot")),
tabPanel(
splitLayout(cellWidths=c("50%","50%"), plotOutput("fits"),plotOutput("etsForecasttPlot")),
tabPanel(
splitLayout(cellWidths=c("50%","50%"), plotOutput("fitu"),plotOutput("etsForecasttPlot"))
)
)
)
)
)
)
)
server <- function(input, output) {
getDataset<-reactive({
if(input$year=='2020')
{
return(df2020)
}
else if (input$year=='2019')
{
return(df2019)
}
else if (input$year=='2018')
{
return(df2018)
}
})
output$caption<-renderText({
paste("Year: ", input$year)
})
output$etsForecasttPlot <- renderPlot({
fitt<-ets(getDataset(),"Network" == "COE")
plot(forecast(fitt,h=input$ahead))
})
output$etsForecastsPlot <- renderPlot({
fits<-ets(getDataset(),"Network"== "SECNet")
plot(forecast(fits, h=input$ahead))
})
output$etsForecastuPlot <- renderPlot({
fitu<-ets(getDataset(),"Network"=="SBUNet")
plot(forcast(fitu,h=input$ahead))
})
output&plot <- renderPlot({
plot(fitt)
})
output&plot <- renderPlot({
plot(fits)
})
output&plot <- renderPlot({
plot(fitu)
})
}
shinyApp(ui = ui, server = server)
I would appreciate any help.
I know I am having two issues wright now
Warning: Error in <-: could not find function "&<-"
47: server [C:\Users\yatestm\Documents\R\Capstone\Capstone\Trial 5/app.R#139]
Error in output & plot <- renderPlot({ : could not find function "&<-"
Warning: Error in ets: y should be a univariate time series
I also think I have an unending loop