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
Plot a Function with Several Arguments in R
Geom_Bar + Geom_Line: with Different Y-Axis Scale
Dist Function with Large Number of Points
Cannot Install Stringi Since Xcode Command Line Tools Update
Increasing Whitespace Between Legend Items in Ggplot2
How to Check If Multiple Strings Exist in Another String
R Bnlearn Eval Inside Function
Writing a Function to Calculate the Mean of Columns in a Dataframe in R
Reconstruct a Categorical Variable from Dummies in R
Map Array of Strings to an Array of Integers
R - Check If String Contains Dates Within Specific Date Range
Convert Byte Encoding to Unicode
How to Embed Plots into a Tab in Rmarkdown in a Procedural Fashion
Calculating the Distance Between Points in Different Data Frames
Convert Data with One Column and Multiple Rows into Multi Column Multi Row Data