Hello everyone,
I''m new to the word of R, and have been working on a report automation project for my job. I can get the app to run locally but get an error during deployment:
An error has occurred
The application failed to start (exited with code 1).
`── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
ggplot2 3.3.0 purrr 0.3.3
tibble 2.1.3 dplyr 0.8.5
tidyr 1.0.2 stringr 1.4.0
readr 1.3.1 forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
dplyr::filter() masks stats::filter()
dplyr::lag() masks stats::lag()
Attaching package: ‘lubridate’
The following object is masked from ‘package:base’:
date
Error in value[3L] : app.R did not return a shiny.appobj object.
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
Execution halted`
Below is my code:
library(shiny)
library(tidyverse)
library(lubridate)
options(shiny.maxRequestSize = 20*1024^2)
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
titlePanel(h1("DTTS Stats Hub", align = "center")),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
width = 3
),
mainPanel(
tableOutput("contents")
)
)
)
server <- function(input, output) {
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$file1
if (is.null(inFile))
return(NULL)
data <- read.csv(inFile$datapath, header = TRUE)
data_sub <- data %>%
select(Reference, System, Category, ResolvedUser, ResolvedTime)
data_sub$ResolvedTime <- as.Date(data_sub$ResolvedTime , format = "%m/%d/%Y")
# Select total resolves
resolves <- data_sub %>%
group_by(ResolvedUser) %>%
count('Reference')
# Select Desired Feilds and Count Results
data_sub_sys <- data_sub %>%
#filter(System == "Service" | System == "Parts Technical" | System == "Virtual Technician" | System == "General Info and Inquiry") %>%
group_by(ResolvedUser, System) %>%
count('Reference')
data_sub_cat <- data_sub %>%
filter(System == "Service") %>%
group_by(ResolvedUser, Category) %>%
count('Reference')
# Widen and Merge Tables
data_cat_wide <- data_sub_cat %>%
spread(Category, n)
data_sys_wide <- data_sub_sys %>%
spread(System, n)
#Combine Tables
total_table <- full_join(data_sys_wide, data_cat_wide)
final_table <- full_join(total_table, resolves)
final_table <- select(final_table, -'"Reference"')
final_table <- rename(final_table, TotalResolves = n)
final_table2 <- final_table %>%
select(ResolvedUser, Service, `Air and Aftertreatment`, Axle, `Base Engine`, Chassis, Electronics, `Fuel System`, Transmission, `Parts Technical`, `General Info and Inquiry`, `Virtual Technician`, TotalResolves)
inFile <- final_table2
})
}
shinyApp(ui, server)
Any help into what I am missing would be much appreciated!
Glad to be a part of the community!