ggvis

legends orientation in ggvis

ε祈祈猫儿з 提交于 2019-11-28 08:58:35
问题 In ggvis how to make legend vertical? mtcars %>% ggvis(x = ~wt, y = ~mpg, fill = ~cyl) %>% layer_points() %>% add_legend("fill",properties = legend_props( legend = list(x = 500, y = 50))) It puts the legends horizontally. I want it to be vertical. 回答1: Try the below code: mtcars %>% ggvis(~wt, ~mpg, size = ~cyl, fill = ~cyl) %>% layer_points() %>% add_legend(c("size", "fill")) Output chart: Hope this helps. Edit: I explored the add_legend properties and unfortunately I do not see any way of

controlling color of factor group in ggvis - r

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 07:41:42
问题 I have a question about controlling the color of datapoints in ggvis. I have a dataframe that I am filtering in multiple ways (within a shiny app in case it matters). This leads to often no observations of the group I am coloring data points by being present in the resulting filtered dataframe. This obviously results in different colors appearing in different plots which is confusing. This is a pretty close example: set.seed(101) dfvis <- data.frame(x = runif(20), y = runif(20), mygroup =

Rstudio shiny not able to use ggvis

有些话、适合烂在心里 提交于 2019-11-27 16:54:43
问题 I have an RStudio Shiny server running and I installed ggvis from https://github.com/rstudio/ggvis but I am not able to reproduce any of the demo examples in the server. When I run R with the same version installed in the server (3.1.0), I can do the following: > library("shiny") > library("ggvis") The ggvis API is currently rapidly evolving. We strongly recommend that you do not rely on this for production, but feel free to explore. If you encounter a clear bug, please file a minimal

custom fill color in ggvis (and other options)

╄→尐↘猪︶ㄣ 提交于 2019-11-27 16:33:48
问题 I'm trying to use ggvis to create a NFL strength-of-schedule chart for the 2014 season. The data comes from FootballOutsiders.com, and later I'll make a Shiny app that automatically scrapes data from the website as it's updated during the season. The example below is pretty close, but I'd like to make a few modifications. I want to... Include the numeric value of "defense" in each cell of the chart, so the visualization resembles the original "df" data frame. Customize the color scale so

How is data passed from reactive Shiny expression to ggvis plot?

左心房为你撑大大i 提交于 2019-11-26 20:58:06
问题 I am getting acquainted with ggvis and I am trying to use it in shiny. I am having trouble understanding how ggvis gets the data from the reactive Shiny expression. Here is the basic app from ggvis GitHub repository: ui.R: shinyUI(pageWithSidebar( div(), sidebarPanel( sliderInput("n", "Number of points", min = 1, max = nrow(mtcars), value = 10, step = 1), uiOutput("plot_ui") ), mainPanel( ggvisOutput("plot"), tableOutput("mtc_table") ) )) server.R: library(ggvis) shinyServer(function(input,

R Conditional evaluation when using the pipe operator %>%

随声附和 提交于 2019-11-26 19:42:11
When using the pipe operator %>% with packages such as dplyr , ggvis , dycharts , etc, how do I do a step conditionally? For example; step_1 %>% step_2 %>% if(condition) step_3 These approaches don't seem to work: step_1 %>% step_2 if(condition) %>% step_3 step_1 %>% step_2 %>% if(condition) step_3 There is a long way: if(condition) { step_1 %>% step_2 }else{ step_1 %>% step_2 %>% step_3 } Is there a better way without all the redundancy? Here is a quick example that takes advantage of the . and ifelse : X<-1 Y<-T X %>% add(1) %>% { ifelse(Y ,add(.,1), . ) } In the ifelse , if Y is TRUE if

R Conditional evaluation when using the pipe operator %>%

浪尽此生 提交于 2019-11-26 08:55:06
问题 When using the pipe operator %>% with packages such as dplyr , ggvis , dycharts , etc, how do I do a step conditionally? For example; step_1 %>% step_2 %>% if(condition) step_3 These approaches don\'t seem to work: step_1 %>% step_2 if(condition) %>% step_3 step_1 %>% step_2 %>% if(condition) step_3 There is a long way: if(condition) { step_1 %>% step_2 }else{ step_1 %>% step_2 %>% step_3 } Is there a better way without all the redundancy? 回答1: Here is a quick example that takes advantage of