How to deploy shinyapp as a two-file app?

I can't get it to work to use rshiny with a ui.R and a server.R. I read so much and tried so much, I don't get it.

However, from what I've understand is that:

  1. These files have to be stored in a subfolder (in my case in "/app")
  2. These files are called server.R and ui.R
  3. In both files shiny will be included as a library:

library(shiny)

  1. I call them in the main file via:

shinyApp(ui, server)

Especially 4. is a subject to change. Sometimes it is

shinyApp(ui.R., server.R)

, sometimes it is

shinyApp(ui = ui, server = server)

, sometimes it is none of that but instead it is

runApp("app")

..

The last is working locally but shinyapps demands through the logs that I shall remove it.
When I use

shinyApp(ui, server)

then the files can't be found. When I try to use a relative path like

ui = /app/ui.R

it is the same, or

ui = ~/app/ui.R

.
I don't know. What exactly do I have to do?

My ui.R file looks like this:

library(shiny)

ui <- dashboardPage(
dashboardHeader(title = "Sensors", titleWidth = 300),
dashboardSidebar(
sidebarMenu(
menuItem("1. Ambient temperature", tabName = "1_Effects", icon = icon("thermometer-half")),
menuItem("2. Humidity", tabName = "2_Effects", icon = icon("tint")),
menuItem("3. Detection limit", tabName = "3_Effects", icon = icon("microscope")),
menuItem("4. Signal noise air", tabName = "4_Effects", icon = icon("signal")),
menuItem("5. Signal noise gas", tabName = "5_Effects", icon = icon("signal")),
menuItem("6. Sensitivity", tabName = "6_Effects", icon = icon("balance-scale")),
menuItem("7. Cross-sensitivity", tabName = "7_Effects", icon = icon("balance-scale")),
menuItem("8. Linearity", tabName = "8_Effects", icon = icon("chart-line")),
menuItem("9. Linearizability", tabName = "9_Effects", icon = icon("chart-line")),
menuItem("10. Sensor response air", tabName = "10_Effects", icon = icon("signature")),
menuItem("11. Sensor response gas", tabName = "11_Effects", icon = icon("signature")),
menuItem("12. Sensor deviations", tabName = "12_Effects", icon = icon("align-right")),
menuItem("13. General", tabName = "13_Effects", icon = icon("linode")),
menuItem("14. Modelling", tabName = "14_Effects", icon = icon("bezier-curve"))
)),
dashboardBody(
#shinyDashboardThemes(theme = "grey_dark"),

tabItems(
  
  ##### 1. Ambient temperature
  tabItem(tabName = "1_Effects",
          h3("Temperature"),
          fluidRow(
            column(12, align="center", plotOutput('plot1_1')
            )),
          fluidRow(
            h2(""),
            box(plotOutput("plot1_2", height = 300)),
            box(plotOutput("plot1_3", height = 300))),
          fluidRow(
            column(12, align="center", plotOutput('plot1_4'))),
  ),

(...)

  tabItem(tabName = "14_Effects",
          h2("Modelling (CCD)"),
          h2(""),
          h3("Effects"),
          fluidRow(
            h2(""),
            column(12, align="center", plotOutput('plot14_1', height = 350))),
          h3("Linear Regression"),
          fluidRow(column(12, align="center", dataTableOutput('table14_1'))),
          h3("Model performance"),
          fluidRow(column(12, align="center", dataTableOutput('table14_2')))
  )
  
)))

When I put the code from ui.R and server.R into the .Rmd where I call them via

shinyApps(ui, server)

it is working flawlessly.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.