Comments (16)
theme elements done in c2b68cb
from shinystan.
Cool. Let's do the rest of these in the update_ggplot_elements branch.
from shinystan.
Actually @dpastoor, instead of putting ggplot2:: everywhere in the code, we might just be able to put a bunch of things like this:
geom_histogram <- ggplot2::geom_histogram
element_line <- ggplot2::element_line
qplot <- ggplot2::qplot
etc.
in a single file that gets loaded before any of these functions are used. Or am I overlooking something?
from shinystan.
As long as it's in a local scope so this doesn't just reintroduce
name conflicts.
- Bob
On Aug 12, 2015, at 5:45 PM, Jonah Gabry [email protected] wrote:
Actually @dpastoor, instead of putting ggplot2:: everywhere in the code, we might just be able to put a bunch of things like this:
geom_histogram <- ggplot2::geom_histogram
element_line <- ggplot2::element_line
qplot <- ggplot2::qplot
etc.in a single file that gets loaded before any of these functions are used. Or am I overlooking something?
—
Reply to this email directly or view it on GitHub.
from shinystan.
Yeah this would be in a local scope and not carry over into the user's R
session when the GUI is closed.
On Wednesday, August 12, 2015, Bob Carpenter [email protected]
wrote:
As long as it's in a local scope so this doesn't just reintroduce
name conflicts.
- Bob
On Aug 12, 2015, at 5:45 PM, Jonah Gabry <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:Actually @dpastoor, instead of putting ggplot2:: everywhere in the code,
we might just be able to put a bunch of things like this:geom_histogram <- ggplot2::geom_histogram
element_line <- ggplot2::element_line
qplot <- ggplot2::qplot
etc.in a single file that gets loaded before any of these functions are
used. Or am I overlooking something?—
Reply to this email directly or view it on GitHub.—
Reply to this email directly or view it on GitHub
#85 (comment).
from shinystan.
@dpastoor I'll see if my strategy works and let you know. I think it would be preferable to not have a zillion ggplot2::fun
's all over the place that make the source code really hard to read.
from shinystan.
@jgabry the problem I have with that is you now have to track any possible ggplot element you use across the package, so any time you want to add something you have to check to say hmm do all the elements I call here actually exist in, shall we call it, ggplot 'local', so any new function you'd need to check the imports list so to speak and you'll end up with a mess of
aes <- ggplot::aes
scale_color_manual
scale_color_discrete
....
On top of that, I don't know if the CRAN people will go for that, I seem to recall reading something about them frowning heavily on that kind of 'ghetto import'.
But I absolutely agree that it will also be a bit of mess to find every call and enforce ggplot::, likewise, it will be tedious actually writing the code.
What about a sort of middle ground:
See if we can define the entry points to where ggplot components may be used in a standalone fashion in another package, maybe that is just launch_shinystan
, but there could be some other functions that would be useable outside shinystan.
Then all we have to do is add the snippet i mentioned in #82 to explicitly load ggplot in those. Inside of shinystan itself that'll always return false since ggplot is attached, so just uses a couple nanoseconds of electrons.
from shinystan.
@dpastoor if we put ggplot2 in Imports and add this
ggplot_fns <- readRDS("ggplot_fns.rds")
lapply(ggplot_fns, function(f) {
assign(f, getFromNamespace(f, "ggplot2"), envir = parent.frame(2))
})
to global_utils.R
(where 'ggplot_fns.rds'
is a character vector of all function names in ggplot2) then I think everything works. Give this branch a look/try.
I think CRAN would care if this were happening in the R/ directory and/or could possibly affect the global environment, but since this is all in inst/ and only relevant while the app is running it would probably be ok.
from shinystan.
@dpastoor The only thing we'd need to worry about for this approach (I think) would be not to give any function we write and use in the app the same name as one in ggplot2.
from shinystan.
@jgabry that sounds like a good approach. I wonder (hope not) if we'd also have to do the same for shiny functions. We could probably mock a little bit by calling shinystan::launch_shinystan (without explicitly loading shinystan) and see what breaks
from shinystan.
I'm a little late on this, but would the import functionality of https://github.com/smbache/import help out?
from shinystan.
I think that import is almost "too elegant" for our purposes. For better or worse this is a hack that gives us the entire flavor of ggplot inside the package, but will also allow single functions to work that depend on ggplot without the explicit attachment that occurs when the shinystan package is loaded (eg the difference between library(shinystan) and shinystan::some_function_depending_on_ggplot.
@jgabry can correct me, but I think the ggplot_fns
this is more of a stopgap until we can better define the use cases of shinystan functions outside of shinystan itself, then come up with a better solution (if one is necessary).
from shinystan.
I've never heard of it but I just read the readme and it looks really
useful.
On Wednesday, August 19, 2015, Jeffrey Arnold [email protected]
wrote:
I'm a little late on this, but would the import functionality of
https://github.com/smbache/import help out?—
Reply to this email directly or view it on GitHub
#85 (comment).
from shinystan.
Thanks for the suggestion. I'll play around with it and see if it can make
this cleaner than the current solution.
On Wednesday, August 19, 2015, Jonah Sol Gabry [email protected] wrote:
I've never heard of it but I just read the readme and it looks really
useful.On Wednesday, August 19, 2015, Jeffrey Arnold <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:I'm a little late on this, but would the import functionality of
https://github.com/smbache/import help out?—
Reply to this email directly or view it on GitHub
#85 (comment).
from shinystan.
@dpastoor yeah hopefully just a temporary fix. I'm not familiar with the
import package. could it be used online inside the app just to
import ggplot?
On Wednesday, August 19, 2015, Jonah Sol Gabry <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:
Thanks for the suggestion. I'll play around with it and see if it can make
this cleaner than the current solution.On Wednesday, August 19, 2015, Jonah Sol Gabry [email protected] wrote:
I've never heard of it but I just read the readme and it looks really
useful.On Wednesday, August 19, 2015, Jeffrey Arnold [email protected]
wrote:I'm a little late on this, but would the import functionality of
https://github.com/smbache/import help out?—
Reply to this email directly or view it on GitHub
#85 (comment)
.
from shinystan.
@jgabry so from my reading of it it is an attempt to emulate the python import functionality, therefore this is a 'script level' import. The pro is it makes your code more robust against namespace clashes since you can explicitly control for them through both renaming or selectively importing. The downside, is if it is like python (which it seems to be based on reading) means imports occur at the .R
file level, at least so it seems. So for example, if we wanted to use this for ggplot, at the top of each file that used ggplot function, we'd have to call import.
I think he alludes to this as noted in the package README
While import will also work for package development, it is meant for R scripts.
I think if we had like a couple ggplot elements that we explicitly wanted to pull in (eg only qplot or the likes) this would be an ideal candidate, however at this point it seems to add an additional dependency and isn't really targeted for, at least at this point, package development
from shinystan.
Related Issues (20)
- use posterior package for handling draws HOT 2
- Check for R version 4.0 HOT 1
- selectizeInput for estimates statistics instead of checkboxGroupInput HOT 1
- Default for "max_treedepth"/"max_td" (11) incorrect? HOT 4
- Add support for CmdStanR objects HOT 3
- diagnostics page doesn't load if `stan_used=FALSE`? HOT 1
- Suppress messages when packages are loaded
- how to raise limit above 1000 parameters? HOT 3
- Shiny stan do not work in ubuntu (tested in ubuntu 20.04 and 16.04 both LTS versions)
- variables missing from drop-down HOT 5
- Problem with LaTeX table: ErrorL subscription out of bounds HOT 6
- Latex for graphs like stan_ac, stan_dens, and others HOT 3
- Rocker script?
- Problem with missing themes HOT 13
- Flickering when selecting parameters on page "ESTIMATE"
- gtools is orphaned - Consider a replacement?
- Issue when launching shinystan demo
- launch_shinystan error message
- toggle view for `exp(param)' ?
- Running ‘testthat.R’/opt/local/Library/Frameworks/R.framework/Resources/bin/BATCH: line 60: 98584 Bus error HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinystan.