Coder Social home page Coder Social logo

Comments (11)

dpastoor avatar dpastoor commented on June 5, 2024

should be a reasonably straightforward fix - give me about 30 minutes and I should have a pull request in with the necessary fixes (adding explicit calls to ggplot for all the theme elements)

from shinystan.

jgabry avatar jgabry commented on June 5, 2024

Hi Andy,

Do you have the code for your package on github or somewhere I can take a
look? Maybe we can find a way around this issue.

That said, while it's always nice to depend on as few packages as possible,
would depending on ggplot2 cause any issues for your package?

Jonah

P.S. It's cool you're using shinystan as part of your package!

On Wednesday, August 12, 2015, Andy Yao [email protected] wrote:

I am developing a package which has one function that calls shinystan to
visualize/diagnose my MCMC sampling. The specific function call would be:

library(my_package)

assuming this.df is in the correct dimensions

shinystan::launch_shinystan(shinystan::as.shinystan(this.df)

And then I get this error:

Loading...
Note: for large models ShinyStan may take a few moments to launch.
Loading required package: shiny

Listening on http://127.0.0.1:6658
Error in ggplot2::theme(...) : could not find function "element_blank"
Error in ggplot2::theme(...) : could not find function "element_blank"

It seems like ggplot2 was not loaded, because library(shinystan) or
library(ggplot2) fixes this problem. I understand that I only imported 2
functions from shinystan, and ggplot2 would still need to be libraried
somewhere in my code. Is there anyway around this without having to depend
on shinystan or ggplot2?


Reply to this email directly or view it on GitHub
#82.

from shinystan.

dpastoor avatar dpastoor commented on June 5, 2024

hmm @jgabry so it looks like the (bigger) issue is that with the Depends on ggplot, (most) all the internal code written for shinystan doesn't explicitly call ggplot in front of every element, eg ggplot2::element_blank(). Makes it easier to type, however if any package wants to call a single function without actually loading shinystan I don't believe it will force ggplot/shiny to load

from shinystan.

jgabry avatar jgabry commented on June 5, 2024

Yeah I had it this way because in one of the older iterations there was a
problem that required explicitly depending on ggplot2. But that problem was
sorted out a while ago so it could probably just be in imports instead of
depends now, and the functions could all be called with the ggplot2::,
which would be unfortunate for the source code but would solve this type of
problem.

On Wednesday, August 12, 2015, Devin Pastoor [email protected]
wrote:

hmm @jgabry https://github.com/jgabry so it looks like the (bigger)
issue is that with the Depends on ggplot, (most) all the internal code
written for shinystan doesn't explicitly call ggplot in front of every
element, eg ggplot2::element_blank(). Makes it easier to type, however if
any package wants to call a single function without actually loading
shinystan I don't believe it will force ggplot/shiny to load


Reply to this email directly or view it on GitHub
#82 (comment).

from shinystan.

andyyao95 avatar andyyao95 commented on June 5, 2024

Hi Jonah and Devin!

Thank you so much for such a prompt reply! My package is on github and you could access it by:

install_github("andyyao95/walkr")
library(walkr)
A <- matrix(1, ncol = 3)
b <- 1
answer <- walkr(A = A, b = b, points = 1000, chains = 5, ret.format = "list")

## this line calls shinystan
explore_walkr(answer)

All of the code is on my github! Again, I really appreciate your help!!

Edit: depending on ggplot2 is surely not a problem for me, since it is so widely used. I was just thinking/wondering that I probably shouldn't need to do that since I don't directly use ggplot2.

from shinystan.

dpastoor avatar dpastoor commented on June 5, 2024

andy,

a quick and dirty fix would be to do

if(!any(grepl("package:ggplot2", search()))) {
    message("loading ggplot2 for shinystan visualizations")
    library(ggplot2, quiet =TRUE)
}

which will load ggplot if it hasn't already been loaded. Ultimately I think you'll be better off
just loading all of shinystan rather than just importing those functions, else I think you might end up picking up a lot of bugs from either ggplot or shiny functions not being available.

from shinystan.

andyyao95 avatar andyyao95 commented on June 5, 2024

Hi Devin,

Wonderful! I'll use that quick and dirty fix for now. I'll be following shinystan updates closely. If you guys update the structure of the depends/imports field I'll try it out and let you guys know. Either way, I could just use this fix or depend on ggplot2. Thanks again.

Andy

from shinystan.

dpastoor avatar dpastoor commented on June 5, 2024

@andyyao95 sounds good - you might need to do that same hack for shiny and/or shinystan as well (you'll find out if it keeps crashing). So if you get any more bugs/crashes just post them here and we can track down the dependency code to make it explicit as we go.

from shinystan.

jgabry avatar jgabry commented on June 5, 2024

@andyyao95 If you install shinystan from this branch does your function work without having to do library(ggplot2)?

from shinystan.

andyyao95 avatar andyyao95 commented on June 5, 2024

@jgabry

Hi Jonah,

This version works perfectly fine. Thank you for solving this issue!!

Andy

from shinystan.

jgabry avatar jgabry commented on June 5, 2024

@andyyao95 great! For now these changes are just on the separate branch but
unless we find a better way or any problems with this we'll get it into the
next release too when that's ready.

On Thursday, August 13, 2015, Andy Yao [email protected] wrote:

@jgabry https://github.com/jgabry

Hi Jonah,

This version works perfectly fine. Thank you for solving this issue!!

Andy


Reply to this email directly or view it on GitHub
#82 (comment).

from shinystan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.