问题
I have a shiny app using the package shinydashboard.
At first, I had all the files as 3 files - global.R, server.R, ui.R.
As files got bigger and messy, I took out the codes for each menus, and placed them in a separate folder. (splitting shiny files - http://shiny.rstudio.com/articles/scoping.html)
everything works, but there's something annoying happening - it displays 'TRUE' at the bottom of the ui of the menus I split into separate folder.
If everything is just in one big file, it doesn't display TRUE.
anyone know why this is happening?
functionally, everything is same.
回答1:
What's happening is that source
returns a list with 2 things inside: value
which is the actual R code inside, and visible
which is whether or not the code returned visibly or invisibly. The TRUE
you are seeing is a reflection of the fact that the code returned visibly.
What you want to do is include the value
of that list. So instead of
source("file.R", local = TRUE)
Change it to
source("file.R", local = TRUE)$value
That should fix it
来源:https://stackoverflow.com/questions/30534674/displaying-true-when-shiny-files-are-split-into-different-folders