shinyapps cannot open the connection when read a csv file

276 views
Skip to first unread message

Joy

unread,
May 20, 2016, 5:33:25 PM5/20/16
to ShinyApps Users
Hi, 

I have a test app that read a csv file and plot the distribution. The app works well on local machine but have some error "cannot open the connection" when deploy to shinyapps.io. Please see my ui.R and server.R below.

ui.R:
library(shinydashboard)

header <- dashboardHeader()

sidebar <- dashboardSidebar(
  
  sidebarMenu(
    
    menuItem("Dashboard", tabName = "tab1"),
    selectInput("index",
                label = "Choose one to forecast:",
                choices = list("Dow Jones"= "DJI",
                               "Russell 1000" = "RUI"
                ),
                selected = "DJI"
    )
    
  )
)

body <- dashboardBody(
  tabItem(tabName = "tab1",plotOutput("plot"))
)

ui <- dashboardPage(
  header,
  sidebar,
  body
)



server.R:
library(shinydashboard)

server  <- function(input, output) {

  dataInput <- reactive({
    ind <- input$index
    imp <- read.csv(paste(ind,'_featureimp.csv',sep = ""))
    return(list(imp=imp,ind=ind))
  })
  
  output$plot <- renderPlot({
    imp <- dataInput()$imp
    hist(imp$importance)
  }
  )

  }
 
I guess the problem is I pass a variable when reading the csv file. Can anyone think any solution to it?

Thanks,
Joy

Aaron Goldenberg

unread,
May 21, 2016, 4:17:30 AM5/21/16
to ShinyApps Users
Try using readr::read_csv. Readr is an RStudio package that works very nicely. 
Reply all
Reply to author
Forward
0 new messages