ggvis

How do I control the axis labels on a ggvis plot where the variables to be plotted are selected interactively?

独自空忆成欢 提交于 2020-01-07 05:03:28
问题 I am trying to create an interactive visualization with the ggvis package. Specifically, the user should be able to select which of the variables should be plotted on which axes. One way to do this was already presented in answer 2 of this question. However in this solution the axes are not labeled correctly: E.g. in this example library("ggvis") library("magrittr") sel <- input_select(names(mtcars),map=as.name) mtcars %>% ggvis(sel,~mpg) %>% layer_points() The y-axis has a label of "reactive

How to change legend position in ggvis?

夙愿已清 提交于 2020-01-05 09:12:34
问题 I would like to change the default position of the legend in a ggvis plot. library(ggvis) data(mtcars) mtcars %>% ggvis(x=~wt, y = ~mpg, fill = ~cyl) %>% layer_points() By default, the legend is on the right side. How to put it on the top? With ggplot you can achieve this simply but I could not find any similar way to do the same with ggvis . library(ggplot2) mtcars %>% ggplot(aes(x=wt, y=mpg, fill=cyl)) + geom_point() + theme(legend.position = 'top') This thread suggests that up until now

How to add tooltip with shares to ggvis histogram?

梦想与她 提交于 2020-01-05 08:53:15
问题 I would like to create an interactive histogram which gives information about the bins by hover. This thread gives answer to how to add tooltip with count numbers. library("ggvis") cocaine %>% ggvis(x = ~weight) %>% layer_histograms() %>% add_tooltip(function(df) (paste("count:", df$stack_upr_ - df$stack_lwr_))) How can I add the share of each bin as well? I should somehow add nrow(cocaine) to ggvis and create the shares from count but I did not succeed on how to achieve that (tried to take

ggvis scatter plot with 95% prediction interval

回眸只為那壹抹淺笑 提交于 2020-01-04 01:19:13
问题 library(ggvis) mtcars %>% ggvis(~wt, ~mpg) %>% layer_points() %>% layer_model_predictions(model = "lm", se = TRUE) The above produces a scatter plot with a fitted regression line and 95% confidence limits on . Question : How to draw a scatter plot with a fitted regression line and 95% prediction limits on ? 回答1: Here is an idea. It probably needs more work to get exactly what you're after though. mtcars.pi = data.frame(mtcars, predict(lm(mpg~wt,data=mtcars), interval="prediction")) mtcars.pi

R ggvis multiple plots from single data frame

纵饮孤独 提交于 2020-01-03 11:52:24
问题 I've searched, so please forgive me if I'm missing something. Let's assume a dataframe that contains Name, Date, Calories, where Calories is the total number of calories that person consumed that day. Name Date Calories Amy 1/1/01 1500 Amy 1/2/01 1600 Amy ... ... Sue 1/1/01 1450 Sue 1/1/02 1500 Sue ... ... Jim ... ... What I'd like to do is to use ggvis to plot calories for each person (Name). I know I can use dplyr's group_by, and get this on a single plot, but that will be too busy. And I

Special symbols in ggvis #no2

你。 提交于 2020-01-03 04:36:05
问题 I know that the question about how to integrate greek symbols into axis titles in ggvis plots was answered by Thomas K in Special symbols in ggvis library(ggvis) title <- "CH\u2084 (\u03BC mol)" mtcars %>% ggvis(~wt, ~mpg) %>% layer_points() %>% add_axis('x', orient = 'top', title = title) The solution seems straightforward but unfortunately does not work for me. I am using R studio and it plots the diagram but instead of the µ mol displays a little question mark in a diamond (rhombus) shape.

ggvis interactive figure does not work as expected using reactive values

拟墨画扇 提交于 2020-01-02 04:43:26
问题 I am having problem with the following example ggvis code which is meant to make a plot that highlights an entire group of points when you hover over any member of that group. I would then like the highlighting to vanish as soon as you hover off. What is happening is that the highlighting initially works but then when you hover off, the highlighting stays, and only vanishes when you hover over another set of points and then hover off them again. library(magrittr) library(dplyr) library(ggvis)

Knitting RMarkdown with ggvis to Word

家住魔仙堡 提交于 2020-01-01 11:59:10
问题 When I try to knit a RMarkdown document with ggvis plots to Word, I get the following message from Rstudio. Error: Functions that produce HTML output found in document targeting docx output. Please change the output type of this document to HTML. Execution halted Does there exist an elegant solution (without too much effort) to make this possible, perhaps using export_png and vg2png ? 回答1: Here is an example: ```{r setup, include=FALSE} library(dplyr) library(ggvis) ``` The following table

Create dynamic ggvis chart from uploaded file in shiny

家住魔仙堡 提交于 2020-01-01 11:55:13
问题 I am trying to use Shiny and ggvis to: 1) upload a data set 2) have the user select 2 columns (x, y) 3) return a ggvis plot displaying (x, y) from the uploaded data set I've tried editing the examples from the Shiny Interactivity page as well as the movie explorer example. However, no chart is displayed. I think my issue is around uploading the data set, but I don't know where to begin... Any suggestions? Note - I've also tried this using rCharts, but I run into similar problems where no

Create dynamic ggvis chart from uploaded file in shiny

十年热恋 提交于 2020-01-01 11:55:08
问题 I am trying to use Shiny and ggvis to: 1) upload a data set 2) have the user select 2 columns (x, y) 3) return a ggvis plot displaying (x, y) from the uploaded data set I've tried editing the examples from the Shiny Interactivity page as well as the movie explorer example. However, no chart is displayed. I think my issue is around uploading the data set, but I don't know where to begin... Any suggestions? Note - I've also tried this using rCharts, but I run into similar problems where no