Comments (7)
I also have the same issue. It would be great if mjs_plot() could process the r variables instead of fixed bare names of the variables.
from metricsgraphics.
I just pushed 0.7.5 which enables accessor parameters in functions to be either bare or quoted (i.e. modified mjs_plot
, mjs_point&
mjs_add_line`). I made a few local tests and it seems to work but if y'all could give it a whirl and let me know that'd be cool.
from metricsgraphics.
I would also agree with the earlier comments and would find it very useful if the code chunk below worked (this is similar to ggplot2::aes_string
). I can confirm that mjs_plot(x = "wt", y = "mpg")
now works.
x = "wt"
y = "mpg"
mtcars %>%
mjs_plot(x=x, y=y) %>%
mjs_point(color_accessor=carb, size_accessor=carb) %>%
mjs_labs(x="Weight of Car", y="Miles per Gallon")
from metricsgraphics.
@hrbrmstr I also confirmed that the 0.7.5 version works fine with quoted strings. But as described correctly by @jrowen the mjs_plot should process R objects as x and y variables as shown in his previous comment.
from metricsgraphics.
This issue has still not been fixed, and I believe it is a very important feature to add for use in Shiny Apps in which the user chooses what fields to plot. And I don't think a fix would be too difficult. I think the real problem is the use of substitute()
inside mjs_plot()
. This seems to be a dangerous function because it forces any input to be an expression. It will force a variable name to be the character expression of that variable name--not the character string that the variable actually represents. And I see no way around it.
As @jrowen mentions, we should be able to just reverse engineer how ggplot2
's aes_string()
handles its input parameters.
aes_string <- function (x = NULL, y = NULL, ...)
{
mapping <- c(compact(list(x = x, y = y)), list(...))
mapping[vapply(mapping, is.null, logical(1))] <- "NULL"
parsed <- lapply(mapping, function(x) parse(text = x)[[1]])
structure(rename_aes(parsed), class = "uneval")
}
from metricsgraphics.
Recently, I ran into a similar issue with the rbokeh
library, so I made an attempt at a fix here. If you have a minute, please give it a try an let me know if it works for you.
devtools::install_github("jrowen/metricsgraphics", ref = "allow_vrbl_names")
from metricsgraphics.
@jrowen I shall, but in the meantime folks can try the "mjs_plot_" version in the dev branch - https://github.com/hrbrmstr/metricsgraphics/tree/dev01
I also added an as_mjsplot
function to take simple ggplot objects and convert them to metricsgraphics ones
from metricsgraphics.
Related Issues (20)
- Use with Reactive Data in Shiny HOT 1
- unable to set x axis limits for histogram HOT 1
- cannot sync plots HOT 2
- mjs_point does not utilize point_size argument HOT 6
- How to render?
- Warning in run(timeoutMs)
- mjs_add_mouseover works in RStudio, but I cannot get it to work with shiny. HOT 5
- Plots render incorrectly
- Can anyone show me how to customize tooltip content in a metricsgrahpics graph within shiny? HOT 2
- Issue with plotting time series after enhancement
- Adjust Chart Padding in Shiny HOT 1
- Adjust Chart Font Sizes in Shiny HOT 2
- Linked charts HOT 4
- Adjust font size of tooltip text?
- mjs_add_marker not working with mjs_histogram
- Dealing with explicitly provided widget id warning when using shiny HOT 4
- mjs_add_line does not display X values correctly with mjs_axis_x(format="plain")
- mjs_axis_x(xax_format = "date") masks y mouseover HOT 1
- Linked Charts with Multiple Lines HOT 1
- metricsgraphics_html returned an object of class `list` instead of a `shiny.tag`
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 metricsgraphics.