There is no package called ‘shinydashboard’

Hi , (sorry my Enlish is not very well)
this problem has troubled me more than six hours already...
now i'm going to tell u what i've done...
(my OS is window 10)
when i use R-studio to publish my code(ui.r and server.r) to
and then it got error like this:

ERROR: An error has occurred. Check your logs or contact the app author for clarification.

and then i goto check my logs which at
it show like this:

2018-09-13T02:26:08.628341+00:00 shinyapps[431829]: Server version: 1.6.6-2
2018-09-13T02:26:08.628376+00:00 shinyapps[431829]: LANG: zh_TW.UTF-8
2018-09-13T02:26:08.628378+00:00 shinyapps[431829]: shiny version: 1.1.0
2018-09-13T02:26:08.628378+00:00 shinyapps[431829]: R version: 3.5.1
2018-09-13T02:26:08.628379+00:00 shinyapps[431829]: httpuv version: 1.4.5
2018-09-13T02:26:08.628391+00:00 shinyapps[431829]: rmarkdown version: 1.10
2018-09-13T02:26:08.628392+00:00 shinyapps[431829]: knitr version: 1.20
2018-09-13T02:26:08.628402+00:00 shinyapps[431829]: jsonlite version: 1.5
2018-09-13T02:26:08.628429+00:00 shinyapps[431829]: RJSONIO version: NA
2018-09-13T02:26:08.628430+00:00 shinyapps[431829]: htmltools version: 0.3.6
2018-09-13T02:26:08.628558+00:00 shinyapps[431829]: Using pandoc at /opt/connect/ext/pandoc2
2018-09-13T02:26:08.770718+00:00 shinyapps[431829]: Using jsonlite for JSON processing
2018-09-13T02:26:08.775818+00:00 shinyapps[431829]: Starting R with process ID: '128'
2018-09-13T02:26:08.775815+00:00 shinyapps[431829]:
2018-09-13T02:26:08.795891+00:00 shinyapps[431829]:
2018-09-13T02:26:08.795893+00:00 shinyapps[431829]: Listening on
2018-09-13T02:26:09.123892+00:00 shinyapps[431829]: Warning: Error in library: there is no package called ‘shinydashboard’
2018-09-13T02:26:09.133638+00:00 shinyapps[431829]: 59: library
2018-09-13T02:26:09.133637+00:00 shinyapps[431829]: 60: stop

and i try to find out what does it means (two days ago until now) ,i'm still don't know how to make it right
p.s. i've read all the solution on Stackoverflow, but i really can't understand how they fix the problem...
could someone can help me? please~

oh my god
after one hour i post this
i cannot believe i find the solution and it works!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

here is the solution:
create a r-script (like ui.r and server.r)
and name it :helper.r
and then put all your packages u have used into it.
then save the file
then miracle is occurred~~~

The default name to use for this third script in your app is global.R. If you name your script as this, then the app will automatically run the entire script during the app's startup (i.e. you don't have to use source) .

This is useful both for loading libraries and for defining global variables for your app.


Thank you for replying me!!
Your soluiton sounds very useful! (I'm new to R)

Can I make sure if I really understand what you said?
You mean the r-script I have created, it don't have to name: helper.r,
instead, normally it would be named:global.R ,right?

And what does this means?
(i.e. you *don't* have to use source ) .
Is it means that I don't have to write library again in the ui.r and server.r?
(Actually , I'm not very sure about what source means in R or R-shiny)

1 Like

Yes, I would recommend renaming the helper.R script to global.R.

Also, yes, if you load libraries or define global variables in the global.R script than you do not need to reload libraries or redefine the variables in your ui.R or server.R file.

Essentially, when you run your shiny application, the global.R script is run and everything in it is then in the global environment and can be accessed by either the ui.R or server.R script.

source is a function that allows you to call scripts inside of other scripts. So as a brief example:

# source in another script that defines variable foo

foo_two <- foo * 2

so in this example, my current script does not define the variable foo. But since I use the source function to call a script that does define the variable foo, I then am able to use the variable foo in the rest of the script. The same thing can be used in a shiny app. But if you are not doing anything super intensive or with a large number of lines, I find it easier to just do this all in the global.R script. If you do have an operation you want to define in global.R that is really long you could always store it in a separate script (i.e. like helper.r to define a set of helper functions) and then source that script in your global.R file.

The real benefit to the global.R file is that you can define things in one place so that both your ui.R and server.R scripts can access them without having to define them in both places.