rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
893 stars 300 forks source link

box() function masked by graphics package #162

Closed theGreatWhiteShark closed 7 years ago

theGreatWhiteShark commented 7 years ago

First of all: great package. But yesterday I discovered that my shiny app and even the minimal version of the shinydashboard example won't run on my machine (R3.3.0, shiny0.14, shinydashboard0.5.3 ) anymore.

The errors look like this: Error in box(plotOutput("plot1", height = 250)) : plot.new has not been called yet

After some digging I found the source of the problem to be the masking of the shinydashboard::box() function by graphics::box().

This is quite odd since the package was loaded after the base one and the //NAMESPACE of the package seems legit. (I use install_github())

Replacing all box() by shinydashboard::box() fixed my app. But there is certainly a better way of doing it.

Cheers, Phil

wch commented 7 years ago

That's really strange -- it sounds like the graphics package was loaded after shinydashboard in your R session. I can't imagine how that would happen, since graphics is one of the base packages that is loaded when R starts

How were you running your application -- in an R session or with Shiny Server (or something else)? And did you compile R yourself?

theGreatWhiteShark commented 7 years ago

Yeah, its really strange. ~/tmp $ R

require( shinydashboard ) box function (which = "plot", lty = "solid", ...) { which <- pmatch(which[1L], c("plot", "figure", "inner", "outer")) .External.graphics(C_box, which = which, lty = lty, ...) invisible() } <bytecode: 0x8fbaf70>

And yes, I compiled R myself. But I did since I started to use the language two years ago. Such things have not happened yet.

But I just realized the error does not show up when starting R without the .Rprofile. I will check package causes the problem.

wch commented 7 years ago

Can you run the following in a new R session and paste the output in a comment?

sessionInfo()
library(shinydashboard)
sessionInfo()
box

Also, please run the same commands after starting R with R --vanilla and paste them as well.

Finally, if you have the commands you used to configure and compile R, it would be helpful if you could provide those as well.

wch commented 7 years ago

Also, this may be relevant: http://stackoverflow.com/a/26935536/412655

theGreatWhiteShark commented 7 years ago

Okay, the problem seems to be at another point:

I wrote my own package including a shiny app based on shinydashboard. And though putting shinydashboard in the //DESCRIPTION:Depends and adding "import( shinydashboard )" to the //NAMESPACE the shinydashboard::box() function was not imported into the package's namespace.

This is nevertheless quite odd since all the other shinydashboard functions are available. (I do not import the graphics package)

wch commented 7 years ago

Two things:

theGreatWhiteShark commented 7 years ago

Nice. Thanks a lot! I must had overlooked the 'Imports" feature when I read Hadley's package book.

importFrom I only use for packages from which I just use one or two functions. But thanks again for the advice.

wch commented 7 years ago

Great!