ggvis

Disappearing values in ggvis when using tooltip on grouped data

元气小坏坏 提交于 2019-12-02 05:28:15
问题 This works fine library(dplyr) library(ggvis) years <- as.factor(c(2013,2013,2014,2014,2015,2015)) months <- c(1,2,1,2,1,2) values <- c(3,2,4,6,5,1) df <- data.frame(years,months,values) df %>% group_by(years) %>% ggvis(~months, ~values) %>% layer_points( fill = ~years) However, when I add a tooltip the points all appear momentarily but only the 2015 values remain df <- cbind(df, id = seq_len(nrow(df))) all_values <- function(x) { if(is.null(x)) return(NULL) row <- df[df$id == x$id,] paste0

Disappearing values in ggvis when using tooltip on grouped data

帅比萌擦擦* 提交于 2019-12-02 01:18:35
This works fine library(dplyr) library(ggvis) years <- as.factor(c(2013,2013,2014,2014,2015,2015)) months <- c(1,2,1,2,1,2) values <- c(3,2,4,6,5,1) df <- data.frame(years,months,values) df %>% group_by(years) %>% ggvis(~months, ~values) %>% layer_points( fill = ~years) However, when I add a tooltip the points all appear momentarily but only the 2015 values remain df <- cbind(df, id = seq_len(nrow(df))) all_values <- function(x) { if(is.null(x)) return(NULL) row <- df[df$id == x$id,] paste0(names(row),": ",format(row), collapse = "<br />") } df %>% group_by(years) %>% ggvis(~months, ~values,

dynamic filtering with input_select() using ggvis in R

陌路散爱 提交于 2019-12-01 18:46:57
问题 I'm using the built in "cocaine" database that comes with the ggvis package in R to visualize the potency counts of cocaine in each state. The R package dplyr was also used. Here's the first six lines of the cocaine dataset: state potency weight month price 1 WA 77 217 1 5000 2 CT 51 248 1 4800 3 FL 68 43 1 3500 4 OH 69 123 1 3500 5 MS 75 118 1 3400 6 VA 73 127 1 3000 The goal was to use input_select() within the ggvis package to create a drop down menu where one could select various states

Using ggvis in Rnw with knitr

喜欢而已 提交于 2019-12-01 09:24:44
I wonder if I can use ggvis in .Rnw with knitr. I tried the following code in RStudio Version 0.98.1091 . But it is not working. \documentclass{book} \usepackage[T1]{fontenc} \usepackage{float} \usepackage{booktabs} \usepackage{dcolumn} \usepackage{geometry} \geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm} \begin{document} \chapter{Test} \begin{figure}[H] << label = Plot1, fig.lp = "Plot1", fig.cap = "Test Plot" >>= library(ggvis) p <- mtcars %>% ggvis(x = ~wt, y = ~mpg) %>% layer_points() print(p) # Commenting this line will compile the document @ \end{figure} \end{document}

Dynamic ggvis object in Shiny

℡╲_俬逩灬. 提交于 2019-12-01 09:23:03
I'm trying to add a dynamic ggvis plot to a Shiny app. First, user picks a dimension, and then adds items from that dimension. For global.R and sample data, see https://gist.github.com/tts/a41c8581b9d77f131b31 server.R: shinyServer(function(input, output, session) { # Render a selectize drop-down selection box output$items <- renderUI({ selectizeInput( inputId = 'items', label = 'Select max 4. Click to delete', multiple = TRUE, choices = aalto_all[ ,names(aalto_all) %in% input$dim], options = list(maxItems = 4, placeholder = 'Start typing') ) }) selected <- reactive({ if (is.null(input$items))

Using ggvis in Rnw with knitr

五迷三道 提交于 2019-12-01 07:31:23
问题 I wonder if I can use ggvis in .Rnw with knitr. I tried the following code in RStudio Version 0.98.1091 . But it is not working. \documentclass{book} \usepackage[T1]{fontenc} \usepackage{float} \usepackage{booktabs} \usepackage{dcolumn} \usepackage{geometry} \geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm} \begin{document} \chapter{Test} \begin{figure}[H] << label = Plot1, fig.lp = "Plot1", fig.cap = "Test Plot" >>= library(ggvis) p <- mtcars %>% ggvis(x = ~wt, y = ~mpg) %>%

Dynamic ggvis object in Shiny

前提是你 提交于 2019-12-01 07:12:07
问题 I'm trying to add a dynamic ggvis plot to a Shiny app. First, user picks a dimension, and then adds items from that dimension. For global.R and sample data, see https://gist.github.com/tts/a41c8581b9d77f131b31 server.R: shinyServer(function(input, output, session) { # Render a selectize drop-down selection box output$items <- renderUI({ selectizeInput( inputId = 'items', label = 'Select max 4. Click to delete', multiple = TRUE, choices = aalto_all[ ,names(aalto_all) %in% input$dim], options =

Getting ggvis::export_png() working

主宰稳场 提交于 2019-12-01 04:36:57
Goal Export a ggvis figure as a PNG file (for inclusion in an .Rmd document). Problem I know essentially nothing about Node.js, other than that it is great and I should know more. I get as far as: library(ggvis) mtcars %>% ggvis(~mpg, ~wt) %>% export_png() Writing to file plot.png Guessing layer_points() module.js:340 throw err; ^ Error: Cannot find module 'd3' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/usr/local/src/vega/index.js:11:6) at Module.

Enhancing ggvis axes

不打扰是莪最后的温柔 提交于 2019-12-01 00:27:43
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=TRUE) but now I am showing every year, rather than the more appropriate 5 year values shown before and

Interactive scatter plots in R, overlay/hover summary/tooltip as user supplied plot function

泪湿孤枕 提交于 2019-11-30 22:15:28
I have been looking into interactive plots in R. I know that there are several packages to create interactive plots, especially scatterplots, but I am looking for a certain functionality. For example this plot . One can hover with the mouse over the buttons to get a small numerical summary of the data behind the point, i.e. a tooltip. When you have a data set with more variables, it is often nice to explore/visualize scores from PCA, or do multi-dimensional-scaling(MDS). But if one would plot the data in an interactive manner, like the example above, the summary when one hovers over the point