title: reading excel files into Shiny
body: <p>I'm new to Shiny and am trying to run an app using data from an excel file. Seems like it should be simple, but can't figure it out. there's load of info out there on more complex tasks (uploading files interactively, where you specify columns, file location etc) - but all I want is an app that uses data from a single excel file that has loaded in the background.</p>
  
  <p>Similar questions have been asked before (<a href="https://stackoverflow.com/questions/26316192/uploading-csv-file-to-shinyapps-io?newreg=0c89cc454db543c1b82f5739205750a3">Uploading csv file to shinyApps.io</a> and <a href="https://stackoverflow.com/questions/24920531/r-shiny-read-csv-file">R Shiny read csv file</a>) but I didn't get a satistactory answer from them.</p>
  
  <p>I have my excel file saved in the same directory as the app.R file, in a folder named 'data'. And I read it into the <code>server</code> part of my script like this:</p>
  
  <pre><code>server &lt;- function(input, output){
    # Read in data
    myDF &lt;- read_excel('data/MyShinyData.xlsx')
  </code></pre>
  
  <p>When I run the app.R file to test the app, it works fine. But when I publish it to the Shiny website using <code>shinyapps::deployApp('pathToWorkingDirectory')</code> I get a grayed out version of the app that has no interactivity. The app also publishes to the website fine if I simulate the data within the app.R file (the excel file is just this simulated data, written to excel with write.xlsx) - its only when I take out the code for simulating the data and replace it with the read_excel command that it stops working. I've also tried with a .csv file instead of .xlsx, but same problem.</p>
  
  <p>I've copied the full code from the app.R file below.</p>
  
  <p>What am I doing wrong? Thanks for your help.</p>
  
  <pre><code>library('ggplot2')
  library('shiny')
  library('psych')
  library('readxl')
  
  #===============
  #This code makes a histogram, a coplot, and a prediction for species richness ('SpNat') given Forest cover ('NBT').
  #===============
  
  m1 &lt;- lm(SpNat ~ NBT, data=myDF) #For prediction. best to create all non-reactive [ie non-updating] code outside the app, so it doesn't have to run every time.
  
  #==========
  # ui section
  #==========
  
  ui &lt;- fluidPage(
  
    ### MAKING A TITLE
    titlePanel("Dashboard based on excel data"),
  
    ### DIVIDING INPUTS TO SIDEBAR VS MAIN PANELS:
    sidebarLayout(
  
      sidebarPanel(                                                           #everything nested in here will go in sidebar
    #dropdown input for coplot:
    tags$h3('Select coplot variables'), #heading
    selectInput(inputId='choiceX', label='Choose X variable', 
                choices=c('Species richness'='SpNat', 'Forest cover'='NBT', 'Pest control'='PC')), #***Choices are concatenated text strings. 
    selectInput(inputId='choiceY', label='Choose Y variable', 
                choices=c('Species richness'='SpNat', 'Forest cover'='NBT', 'Pest control'='PC')),
    selectInput(inputId='choiceZ', label='Choose conditioning variable', 
                choices=c('Species richness'='SpNat', 'Forest cover'='NBT', 'Pest control'='PC')),
  #checkbox input for pairs plots:
    tags$h3('Select variables for pairs plots'), #heading
    checkboxGroupInput(inputId='vars', label='Choose at least two variables for pairs plot', 
                     selected=c('SpNat', 'NBT', 'PC'), #'determines which vars start off checked. Important for pairs, cos &lt;2 and plot wont work.
                     choices=c('Species richness'='SpNat', 'Forest cover'='NBT', 'Pest control'='PC')), #***Server receives input as a single concatenated text 
  
  #slider input for prediction:  
    tags$h3('Predicting forest cover'), #heading
    sliderInput(inputId='num',label='Pick a forest cover level', value=10, min=1, max=100)),
  
    mainPanel(                                                               #everything nested in here will go in main panel
  #specify output for app, including headings:
    tags$h3('Coplot:'),
    plotOutput(outputId='coplot'),
    tags$h3('Histogram:'),  
    plotOutput(outputId='pairs'),
    tags$h3('Predicted species richness:'),  
    verbatimTextOutput('prediction'))))
  
  #==========
  # server section
  #==========
  
  server &lt;- function(input, output){
    # Read in data
    myDF &lt;- read_excel('data/MyShinyData.xlsx') #don't need full path
    myDF$PC &lt;-  as.factor(myDF$PC)
    myDF &lt;- select(myDF, SpNat, NBT, PC)
  
    #create output object, and name it so it corresponds to the ui output function ID, plus use the ui input ID to create it: 
    output$coplot &lt;- renderPlot(
      ggplot(myDF, aes_string(input$choiceX, input$choiceY, col=input$choiceZ)) + geom_point())    #note use of aes_string to allow inputID use direct.
    output$pairs &lt;- renderPlot({
      pairs.panels(subset(myDF, select=input$vars))})
    output$prediction &lt;- renderPrint({
      newData &lt;- data.frame(NBT=input$num)
      cat(predict(m1, newdata = newData))
    })
  }
  
  #==========
  # and stitch together
  #==========
  
  shinyApp(ui=ui, server=server)
  </code></pre>