Search code examples
rshinyquantmod

Could not find the function "getSymbols" while using ShinyApps.io


I just finished building a trading strategy in Rstudio, and I planed to deploy it on the ShinyApps.io. Here comes a problem.

The first thing is that there is always a warning message like this:

Warning messages:
1: In getFromNamespace("checkEncoding", "shiny")(file) :
  The file "F:\newFinal/server.R" is not encoded in UTF-8. Please convert its encoding to UTF-8 (e.g. use the menu `File -> Save with Encoding` in RStudio). See http://shiny.rstudio.com/articles/unicode.html for more info. Falling back to the encoding "native.enc".
2: In getFromNamespace("checkEncoding", "shiny")(file) :
  The file "F:\newFinal/server.R" is not encoded in UTF-8. Please convert its encoding to UTF-8 (e.g. use the menu `File -> Save with Encoding` in RStudio). See http://shiny.rstudio.com/articles/unicode.html for more info. Falling back to the encoding "native.enc".

Even I saved the file with encoding UTF-8, it still shows me that warning each time I deploy the application.

Another thing is that I can't source the other file in ShinyApps, like this:

source("helpers.R")
#source("loadfunction.R")
source("main2.R")
#source("main.R")
source("plotperiod.R")

The following logs shows that the system can not find the function "getSymbols".

2014-11-30T05:01:21.252572+00:00 shinyapps[shuttle]: rmarkdown version: 0.0.0
2014-11-30T05:01:21.251463+00:00 shinyapps[shuttle]: Shiny version: 0.10.2.1
2014-11-30T05:01:21.253004+00:00 shinyapps[shuttle]: knitr version: 0.0.0
2014-11-30T05:01:21.517405+00:00 shinyapps[shuttle]: 
2014-11-30T05:01:21.517408+00:00 shinyapps[shuttle]: Starting Shiny with process ID: '25'
2014-11-30T05:01:21.524432+00:00 shinyapps[shuttle]: 
2014-11-30T05:01:21.524434+00:00 shinyapps[shuttle]: Listening on http://0.0.0.0:35292
2014-11-30T05:01:22.543644+00:00 shinyapps[shuttle]: Error in eval(expr, envir, enclos) : could not find function "getSymbols"
2014-11-30T05:08:22.837418+00:00 shinyapps[shuttle]: R version: 3.1.1
2014-11-30T05:08:22.838692+00:00 shinyapps[shuttle]: rmarkdown version: 0.0.0
2014-11-30T05:08:22.837469+00:00 shinyapps[shuttle]: Shiny version: 0.10.2.1
2014-11-30T05:08:22.839117+00:00 shinyapps[shuttle]: knitr version: 0.0.0
2014-11-30T05:08:23.115849+00:00 shinyapps[shuttle]: 
2014-11-30T05:08:23.115852+00:00 shinyapps[shuttle]: Starting Shiny with process ID: '12'
2014-11-30T05:08:23.122818+00:00 shinyapps[shuttle]: 
2014-11-30T05:08:23.122821+00:00 shinyapps[shuttle]: Listening on http://0.0.0.0:56837
2014-11-30T05:08:31.778390+00:00 shinyapps[shuttle]: Shiny version: 0.10.2.1
2014-11-30T05:08:31.779947+00:00 shinyapps[shuttle]: knitr version: 0.0.0
2014-11-30T05:08:31.778335+00:00 shinyapps[shuttle]: R version: 3.1.1
2014-11-30T05:08:31.779528+00:00 shinyapps[shuttle]: rmarkdown version: 0.0.0
2014-11-30T05:08:32.080184+00:00 shinyapps[shuttle]: 
2014-11-30T05:08:32.080190+00:00 shinyapps[shuttle]: Starting Shiny with process ID: '25'
2014-11-30T05:08:32.087453+00:00 shinyapps[shuttle]: 
2014-11-30T05:08:32.087455+00:00 shinyapps[shuttle]: Listening on http://0.0.0.0:55221
2014-11-30T05:08:33.083355+00:00 shinyapps[shuttle]: Error in eval(expr, envir, enclos) : could not find function "getSymbols"
2014-11-30T05:11:27.282921+00:00 shinyapps[shuttle]: Shiny version: 0.10.2.1
2014-11-30T05:11:27.284559+00:00 shinyapps[shuttle]: knitr version: 0.0.0
2014-11-30T05:11:27.282870+00:00 shinyapps[shuttle]: R version: 3.1.1
2014-11-30T05:11:27.284140+00:00 shinyapps[shuttle]: rmarkdown version: 0.0.0
2014-11-30T05:11:27.554872+00:00 shinyapps[shuttle]: 
2014-11-30T05:11:27.554875+00:00 shinyapps[shuttle]: Starting Shiny with process ID: '12'
2014-11-30T05:11:27.561737+00:00 shinyapps[shuttle]: 
2014-11-30T05:11:27.561740+00:00 shinyapps[shuttle]: Listening on http://0.0.0.0:33719
2014-11-30T05:11:34.514578+00:00 shinyapps[shuttle]: Shiny version: 0.10.2.1
2014-11-30T05:11:34.516275+00:00 shinyapps[shuttle]: knitr version: 0.0.0
2014-11-30T05:11:34.514528+00:00 shinyapps[shuttle]: R version: 3.1.1
2014-11-30T05:11:34.515806+00:00 shinyapps[shuttle]: rmarkdown version: 0.0.0
2014-11-30T05:11:34.784230+00:00 shinyapps[shuttle]: 
2014-11-30T05:11:34.784232+00:00 shinyapps[shuttle]: Starting Shiny with process ID: '25'
2014-11-30T05:11:34.791157+00:00 shinyapps[shuttle]: 
2014-11-30T05:11:34.791160+00:00 shinyapps[shuttle]: Listening on http://0.0.0.0:47994
2014-11-30T05:11:36.003478+00:00 shinyapps[shuttle]: Error in eval(expr, envir, enclos) : could not find function "getSymbols"
2014-11-30T05:12:10.176603+00:00 shinyapps[shuttle]: R version: 3.1.1
2014-11-30T05:12:10.177833+00:00 shinyapps[shuttle]: rmarkdown version: 0.0.0
2014-11-30T05:12:10.176681+00:00 shinyapps[shuttle]: Shiny version: 0.10.2.1
2014-11-30T05:12:10.178237+00:00 shinyapps[shuttle]: knitr version: 0.0.0
2014-11-30T05:12:10.483932+00:00 shinyapps[shuttle]: 
2014-11-30T05:12:10.483938+00:00 shinyapps[shuttle]: Starting Shiny with process ID: '33'
2014-11-30T05:12:10.491297+00:00 shinyapps[shuttle]: 
2014-11-30T05:12:10.491300+00:00 shinyapps[shuttle]: Listening on http://0.0.0.0:35973
2014-11-30T05:12:11.486962+00:00 shinyapps[shuttle]: Error in eval(expr, envir, enclos) : could not find function "getSymbols"

Solution

  • Not sure if this is going to solve the problem but in order to source the files, you will need to add the local argument and set it to TRUE as follows:

    source("helpers.R", local=TRUE)
    source("main2.R", local=TRUE)
    source("plotperiod.R", local=TRUE)