2

I would like to know why when I open a shiny app in r-studio I have to run all packages and files before run it the app. I would like just clic in the run app botton and that everything be loaded automatically. Is there a clean solution for this?

This is the error I have:

Listening on http://127.0.0.1:4659
Warning: Error in dropNulls: object 'df1' not found
  61: dropNulls
  60: getSliderType
  59: sliderInput

df1 is a excel file and the code is in server.R in shinyServer(function(input, output) {})

df1=data.frame(read_excel("C:/Users/Desktop/Prueba/Base.xlsx", sheet = "1.1.1"))

and

library(readxl)

is before the "shinyServer(....)"

JRN
  • 213
  • 1
  • 10
  • 2
    You can have the library calls at the top of your shiny app if you'd like. That would save you having the call them manually. When you say `library(readxl` is before `shinyServer(...)` what exactly do you mean? It needs to be before the call to `read_excel`. – Greg Sep 12 '19 at 15:12
  • 2
    The error you posted doesn't seem to come from the code you posted. You seem to define `df1` locally inside this `renderPlotly` call, but the error seems to come from a responsive `sliderInput`. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Sep 12 '19 at 15:23
  • @Greg you can see my server.R code in a edit – JRN Sep 12 '19 at 15:25
  • @MrFlick you can se my ui and server code in a edit – JRN Sep 12 '19 at 15:35
  • 2
    Duplicate of: https://stackoverflow.com/questions/24111290/r-shiny-make-slider-value-dynamic. The `df1` variables doesn't exist in your `ui.R` file. You would need to create a reactive element on the server and update the UI after you load your data. – MrFlick Sep 12 '19 at 15:44
  • 1
    thks! With a global.R file where I have all packages and files it resolves. – JRN Sep 12 '19 at 16:08
  • @JRN you can make that into an answer. – Roman Luštrik Sep 12 '19 at 18:40

1 Answers1

0

It resolves creating a global.R file in the same direction that ui.R and server.R. Thks to MrFlick for the information.

JRN
  • 213
  • 1
  • 10