ggvis

ggvis::export_png on Windows

走远了吗. 提交于 2019-12-10 18:49:08
问题 Similar to Getting ggvis::export_png() working but I'm trying to get this working in RStudio on Windows. I've installed node.js and downloaded vega and added ./bin to my PATH, but I get the error mtcars %>% ggvis(~wt, ~mpg) %>% layer_points() %>% export_png Writing to file plot.png Error in vega_file(vis, file = file, type = "png") : Conversion program vg2pngnot found. 来源: https://stackoverflow.com/questions/27002277/ggvisexport-png-on-windows

Install v2png program from vega (node.js module) on Windows

一笑奈何 提交于 2019-12-10 16:10:08
问题 The export_png() function in the R ggvis package requires us to have the program vg2png installed, from the node.js module vega . (source: R Documentation ) I have node and npm installed on windows, and I ran npm install vega . This is the output that I got on running npm install vega : C:\Users\username>npm install -g trifacta/vega \ > canvas@1.1.6 install C:\Users\username\AppData\Roaming\npm\node_modules\vega\node_modules\canvas > node-gyp rebuild | C:\Users\username\AppData\Roaming\npm

ggvis side-by-side barchart grouped by second variable

强颜欢笑 提交于 2019-12-10 13:58:00
问题 I am in process of migrating from Excel to ggvis for data analysis. For a typical grouped bar chart with two variables, however I have difficulty to plot bar chart side-by-side instead of stacked . The following data has four steps A, B, C, D with "ratio" data from two features cc, ca. My attempt is to plot the ratio from cc and ca features side-by-side. However, the default plot with stack the two data together. Check the ggvis vignetts has an option to set stack =FALSE. But it would overlap

ggvis: Interaction Plot

流过昼夜 提交于 2019-12-10 11:08:20
问题 I used to make interaction plot with ggplot2 and code is given below. Now I want to reproduce the same plot with ggvis as shown below which not the same as ggplto2 output. How can I get the same plot with ggvis ? library(ggplot2) p <- qplot(as.factor(dose), len, data=ToothGrowth, geom = "boxplot", color = supp) + theme_bw() p <- p + labs(x="Dose", y="Response") p <- p + stat_summary(fun.y = mean, geom = "point", color = "blue", aes(group=supp)) p <- p + stat_summary(fun.y = mean, geom = "line

ggvis - add_legend with multiple data and position legend inside graph

半世苍凉 提交于 2019-12-10 10:24:35
问题 I'm trying to add legends with arbitrary text in a ggvis plot using data from different dataframes. I have tried using add_legend() but I have not idea about what parameters to use. Using plot() is very simple using the legend() function but it has been very hard to find a way to do it using ggvis() Here is a simple example of what I have using plot() : df1 = data.frame(x = sample(1:10), y = sample(1:10)) df2 = data.frame(x = 1:10, y = 1:10) df3 = data.frame(x = 1:10, y = sqrt(1:10)) plot(df1

I can't get ggvis scales to remain fixed with reactive input

会有一股神秘感。 提交于 2019-12-10 09:53:41
问题 I'm trying to create a shiny app that allows the user to select certain groups to plot on a ggvis graph. The problem I'm having is that if I map reactive data to properties of the points (like the point fill, shape, etc.), the scale resets every time the user updates the groups. So the mapping of group identity to fill color does not remain constant. I tried to fix this by hard coding group id to fill color in a reactive element, but then I start getting difficult to interpret errors when the

legends on ggvis graph are overlaping when using tooltip

隐身守侯 提交于 2019-12-09 07:03:07
问题 I'm generating a graph with ggvis and the legends are in top of each-other. library(ggvis) df1 <- data.frame(x=c(0.6,1,1.4), y=c(-2, -.8, -0.2), number=c(10,8,6), type=c('A', 'A', 'B')) df1 %>% ggvis(x = ~x, y = ~y) %>% layer_points(shape=~type, fill=~number) How can I fix this? Thanks! Steven's solution works for the simple example but It does not work when you add a tooltip: library(ggvis) df1 <- data.frame(x=c(0.6,1,1.4), y=c(-2, -.8, -0.2), number=c(10,8,6), type=c('A', 'A', 'B'), id=c(1

Enhancing ggvis axes

自作多情 提交于 2019-12-09 01:19:37
问题 I am looking for the best way to enhance a chart library(dplyr) library(ggvis) df <- data.frame(Year=c(1954:2013), Count=rep(as.integer(c(1,3,4,2)),15)) df %>% ggvis(~Year,~Count) I would like to show only whole numbers in the y-axis and remove the thousand-comma in the x-axis I have coerced both fields to factors with this hack df %>% ggvis(~as.factor(Year),~as.factor(Count)) %>% layer_points() %>% add_axis("y", title="Count") %>% add_axis("x", title="Year") %>% scale_ordinal("y", reverse

ggvis add_tooltip showing only one value for layer_lines

匆匆过客 提交于 2019-12-08 10:52:33
问题 When hovering over a line graph created with ggvis, I see only the first value of a data.frame displayed, regardless of where I move my mouse. Example: library(ggvis) mtcars %>% ggvis(~wt, ~mpg) %>% layer_lines() %>% add_tooltip(function(df) df$wt) I get the value 1.513 now matter where I hover. This problem does not happen when using layer_points . 来源: https://stackoverflow.com/questions/27671718/ggvis-add-tooltip-showing-only-one-value-for-layer-lines

R: ggvis - HTML function - failing to “add_tooltip()”

Deadly 提交于 2019-12-08 07:24:27
问题 this is a basic question about ggvis. I've googled, but still... I want that, when someone hovers over a specific date (2014-12-05), the tooltip will show: 3,188 sessions (please, notice the comma).On so on for everyday on the data frame. Have this df: structure(list(date = structure(1:31, .Label = c("2014-12-01", "2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06", "2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11", "2014-12-12", "2014-12-13", "2014-12-14",