ggvis

How do I reference a clicked point on a ggvis plot in Shiny

邮差的信 提交于 2019-12-04 19:32:28
I wish to use the values of a clicked point for further processing but am unclear how to reference the data library(shiny) library(ggvis) library(dplyr) df <- data.frame(a=c(1,2),b=c(5,3)) runApp(list( ui = bootstrapPage( ggvisOutput("plot") ), server = function(..., session) { # function to handle click getData = function(data,location,session){ if(is.null(data)) return(NULL) # This returns values to console print(glimpse(data)) # Observations: 1 # Variables: # $ a (int) 2 # $ b (int) 3 } # create plot df %>% ggvis(~a, ~b) %>% layer_points() %>% handle_click(getData) %>% bind_shiny("plot") #

How do I export and host a ggvis chart on my own webserver?

夙愿已清 提交于 2019-12-04 13:50:01
问题 As I understand ggvis runs on top of shiny. But I can't figure out how to export all the files needed for running a single ggvis chart on a webserver without R/shiny. 回答1: That won't be possible for interactive plots since "every interactive ggvis plot must be connected to a running R session" (via ggivs basics). However, it is possible with ones that don't require reactive values. CAVEAT ggvis is still rly new, so YMMV with 0.2.x for the following+. I gave the various ggvis/knitr print

Shiny/ggvis Reactivity to Subset Plot Data

空扰寡人 提交于 2019-12-04 11:22:43
After seeing a talk on GGVIS, I have been trying my hand unsuccessfully at creating my first Shiny/ggvis app. My plot works in R, but when I try to migrate it into a Shiny app for display on the web I get nothing. The radio buttons are displayed and from what I can tell seem to be working (I tested using the table from rStudio/Shiny/Reactivity tutorial, but it doesn't seem to place nice with my ggvis plot). I have been following the tutorials on Rstudio and using pieces from the demo folder in the ggvis source code. I am trying to create a simple kernel density plot that subsets data based on

Knitting RMarkdown with ggvis to Word

杀马特。学长 韩版系。学妹 提交于 2019-12-04 09:34:56
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 ? Here is an example: ```{r setup, include=FALSE} library(dplyr) library(ggvis) ``` The following table looks fine... As long as I don't include this plot below ```{r, echo=FALSE, include=FALSE} p <- pressure %>%

ggVis : creating a plot with multiple layers on different dataset

帅比萌擦擦* 提交于 2019-12-04 03:10:47
I'm trying to reproduce a ggplot2 plot using ggvis. The plot aims at representing the coordinates of points (from a Correspondence Analysis) together with their clusters (hclust) Standard Dispersion Ellipses. TL; DR I'd like to make a ggvis plot with multiple layers based on multiple datasets. Thus, the functional/pipe approach stops me from grouping one of the layers and not the other. The whole (briefly commented) code is there : https://gist.github.com/RCura/a135446cda079f4fbc10 Here's the code for creating the data: a <- rnorm(n = 100, mean = 50, sd = 5) b <- rnorm(n = 100, mean = 50, sd =

R: How to change plot background color for a specific range in ggvis shiny app

血红的双手。 提交于 2019-12-03 16:13:29
I have a simple shiny app like below and you can run it. The plots are created by ggvis and user can choose student name from inputSelect . In the plots, I want to change the color of background in specific score range. For example, in each plot , the color of plot background for the score higher than 80 or lower than 50 are highlighted with blue(See picture attached). I was trying to add layers and draw rectangles onto plot using layer_rects() , but the problem is the values of x-axis are changed if different students are chosen.Anyone did this before or any ideas? And is it possible if I

How do I export and host a ggvis chart on my own webserver?

半世苍凉 提交于 2019-12-03 09:32:37
As I understand ggvis runs on top of shiny. But I can't figure out how to export all the files needed for running a single ggvis chart on a webserver without R/shiny. That won't be possible for interactive plots since "every interactive ggvis plot must be connected to a running R session" (via ggivs basics ). However, it is possible with ones that don't require reactive values. CAVEAT ggvis is still rly new, so YMMV with 0.2.x for the following+. I gave the various ggvis/knitr print functions a quick try but didn't manage to generate the whole document (i.e with the necessary libraries). If

legends on ggvis graph are overlaping when using tooltip

筅森魡賤 提交于 2019-12-03 08:54:33
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:3)) tooltip <- function(x) { if(is.null(x)) return(NULL) row <- df1[df1$id == x$id, ] paste0(names(row)

Dynamic resizing of ggvis plots in shiny apps

故事扮演 提交于 2019-12-03 07:48:55
问题 When adding a ggvis plot to a shiny app, the width and height of the plot are fixed and don't automatically adjust to the size of the div the ggvis object is placed in. This obviously causes some problems when app users have different screen sizes for instance, or adjust the size of the app window. It's possible to modify the size of the ggvis object on the server side using set_options, but this doesn't really help since I don't think there is a way to pass the size of the div to the server

Rstudio shiny ggvis tooltip on mouse hover

余生长醉 提交于 2019-12-02 22:54:02
In the example below, I have an interactive shiny ggvis plot, but I added a long column that is a long string and for some reason, my hover pop-up shows wt and mpg but does not show long . Also, if the list of elements in the legend is too long, they are hidden at the bottom right corner of the plot. Is there any way to stack these in several columns in the legend? Any ideas? # ui.R library(ggvis) shinyUI(pageWithSidebar( div(), sidebarPanel( sliderInput("n", "Number of points", min = 1, max = nrow(mtcars), value = 10, step = 1), uiOutput("plot_ui") ), mainPanel( ggvisOutput("plot"),