R Shiny - Ui.R Seems to Not Recognize a Dataframe Read by Server.R

R Shiny - ui.R seems to not recognize a dataframe read by server.R

The problem is you are using df.shiny$Facility in your ui.R file and df.shiny is not defined there. The ui cannot see all the variables in the server, they have other ways to communicate.

To get this to work, you need to build the selectInput on the server, and then render it in the UI. In your server, add

shinyServer(function(input, output, session) {
output$facilityControl <- renderUI({
facilities <- levels(df.shiny$Facility)
selectInput('xrow', 'Facility', facilities )
})

selectedData <- reactive({ subset(df.shiny, Facility %in% input$xrow) })
output$plot1 <- renderPlot({ qcc(selectedData$ITBpct, type = 'xbar.one') })
})

and then change the ui to

shinyUI(pageWithSidebar(
headerPanel('SPC Chart by Facility'),
sidebarPanel( uiOutput("facilityControl" ),
mainPanel( plotOutput('plot1') )
))

How to call a df variable as the input for a t-test in shiny?

Try using

output$ttest <- renderPrint({
t.test(x = df[[input$Var1]])
})

Server Code for Shiny-Server for a Specific App is not showing any of the Dataframes

This stems from a service token issue.
The best way is to just create a service token and session that maintains an open connection and refreshes the token.

I fixed this issue by backing the token directly into the app via JSON and having the app call the JSON file within the directory the shiny app was stored in under the /srv/ directory. You can download a copy of the service account information and store it in the working directory of the app:

root@miradashboard1:/srv/shiny-server/Apps/CSM# ls
miradashboard-f89f243d0221.json server.R ui.R

Then make sure you call the service token within the server.R and ui.R.

service_token <- gar_auth_service(json_file="/srv/shiny-server/Apps/CSM/miradashboard-f89f243d0221.json")


Related Topics



Leave a reply



Submit