I created a Shiny app to draw plots from .csv files.
The app is pretty basic where people can upload their .csv files (from a specific template) and the data file will be modified to create several graphs.
Recently someone asked me to have the calculations generated in a table format so I wanted to add that to the app. I managed to have everything working through and I can see the table with the respective calculations in the viewer pane when testing the app but once I deploy the app through shinyapps.io, the table does not show up and instead I have the following message:
Error: An error has occurred. Check your logs or contact the app author for clarification.
When I check the logs I only have this:
2021-07-30T15:00:26.212649+00:00 shinyapps[4181864]: 115: exprFunc [/srv/connect/apps/PK_Modelling/app.R#92]
2021-07-30T15:00:26.212650+00:00 shinyapps[4181864]: 114: widgetFunc
2021-07-30T15:00:26.212652+00:00 shinyapps[4181864]: 112: func
2021-07-30T15:00:26.212651+00:00 shinyapps[4181864]: 113: htmlwidgets::shinyRenderWidget
2021-07-30T15:00:26.212653+00:00 shinyapps[4181864]: 99: renderFunc
2021-07-30T15:00:26.212665+00:00 shinyapps[4181864]: 13: runApp
2021-07-30T15:00:26.212653+00:00 shinyapps[4181864]: 98: renderFunc
2021-07-30T15:00:26.212667+00:00 shinyapps[4181864]: 6: eval
2021-07-30T15:00:26.212667+00:00 shinyapps[4181864]: 7: connect$retry
2021-07-30T15:00:26.212663+00:00 shinyapps[4181864]: 94: renderFunc
2021-07-30T15:00:26.212664+00:00 shinyapps[4181864]: 93: output$table
2021-07-30T15:00:26.212666+00:00 shinyapps[4181864]: 12: fn
2021-07-30T15:00:26.212667+00:00 shinyapps[4181864]: 5: eval
So I actually don’t know what is wrong.
Here is the code for the shiny app with some parts I need to remove for confidentiality reasons:
library(shiny)
library(DT)
library(ggplot2)
library(gridExtra)
library(ggpubr)
library(MASS)
library(RColorBrewer)
library(ggforce)
library(tibble)
library(tidyr)
library(scales)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel(p("Analysis of data", style = "color:#3474A7")),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(width = 3,
helpText("Please note that CSV file should contain 7 columns named: <STDNR>, <STD>, <ROUTE>, <DOSE>, <TIME>, <PLASMA> and <BLOOD>"),
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
textInput("CPD", label = "Compound Name"),
sliderInput("HCT", label = "HCT",
min = 0, max = 1, value = 0.5),
numericInput("Bmax", label = "Bmax", value = 160),
numericInput("Kd", label = "Kd", value = 1),
numericInput("Kns", label = "Kns", value = 0.35)
),
# Show a plot of the generated distribution
mainPanel( width =9,
#Output: Tabset w/ plots
tabsetPanel(type = "tabs",
tabPanel("PK over time", plotOutput("plot1", width="1200px",height="900px")),
tabPanel("Blood to Plasma Ratio", plotOutput("plot4", width="1200", heigh="600")),
tabPanel("RBC Binding", plotOutput("plot2", width="1200", heigh="600")),
tabPanel("RBC Occupancy", plotOutput("plot3", width="1200", heigh="600")),
tabPanel("Table with Calculations", DT::dataTableOutput("table"))
)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
dt <- reactive({
req(input$file1)
read.csv(input$file1$datapath)
})
output$table <-DT::renderDataTable({
dt=dt()
dt$RBC <- Calculations
dt$BP <- Calculations
dt$OCC <- Calculations
is.num <- sapply(dt, is.numeric)
dt[is.num] <- lapply(dt[is.num], round, 2)
return(datatable(dt, extensions="Buttons",
options = list(dom='lBfrtip',
buttons=c('copy', 'csv', 'excel', 'pdf'))))
})
output$plot2 <- renderPlot({
plot2
})
output$plot1 <- renderPlot({
plot1
})
output$plot4 <- renderPlot({
plot4
})
output$plot3 <- renderPlot({
plot3
})
}
# Run the application
shinyApp(ui = ui, server = server)
Any thoughts on what has gone wrong?
Thank you