ggvis

Setting ranges for a bar chart in R and displaying count of items

陌路散爱 提交于 2019-12-08 01:20:33
问题 I have created a data frame from iris dataset using the following command: new_iris = data.frame(iris$Species,iris$Sepal.Length) range(iris$Sepal.Length) The second command tells me the range of the Sepal.Length. I want to implement a bar plot using plotly or ggplot2 such that the code decides the ranges of Sepal.Length automatically and then each range contains one bar which gives the count of all the Sepal.Length values in that range. So let's say if the ranges decided are "2-4","4-6","6-8"

ggvis plots rendered using bind_shiny() aren't reactive

荒凉一梦 提交于 2019-12-07 12:59:45
问题 I think I'm missing some basic aspect of ggvis + shiny. Following the tutorials, plots are constructed in server.R using a series of %>% pipes, ending with bind_shiny, which associates the plot with an identifier that can be referred to in ui.R What I don't get though is that the plot itself is not reactive in the way that code within renderTable(), renderText() or reactive() will be. So if I want to refer to an input parameter like input$x in defining the plot, it won't work, I'll get an

Rendering ggvis controls in shiny

一曲冷凌霜 提交于 2019-12-07 10:42:15
问题 I'm having trouble getting an input slider to render in a ggvis plot within a shiny app. The plots render fine without the input slider but after adding it shiny throws this error: Listening on http://xxxxxxxxxxxxxx Error in eval(expr, envir, enclos) : could not find function "compdat" server.R: library(shiny) library(ggvis) data<-data.frame(var1=rnorm(30,5,2.3),var2=rbeta(30,1.5,.8),var3=rnorm(30,10,2.5)) shinyServer(function(input, output,session) { compdat<-reactive({data[, c(input$xInp

Setting ranges for a bar chart in R and displaying count of items

丶灬走出姿态 提交于 2019-12-06 15:21:41
I have created a data frame from iris dataset using the following command: new_iris = data.frame(iris$Species,iris$Sepal.Length) range(iris$Sepal.Length) The second command tells me the range of the Sepal.Length. I want to implement a bar plot using plotly or ggplot2 such that the code decides the ranges of Sepal.Length automatically and then each range contains one bar which gives the count of all the Sepal.Length values in that range. So let's say if the ranges decided are "2-4","4-6","6-8", I should get 3 bars which give me a count of all the sepal.length values between "2-4","4-6" and "6-8

ggvis: Interaction Plot

☆樱花仙子☆ 提交于 2019-12-06 05:52:06
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", aes(group = supp)) p <- p + theme(axis.title.x = element_text(size = 12, hjust = 0.54, vjust = 0)) p

ggvis plots rendered using bind_shiny() aren't reactive

允我心安 提交于 2019-12-06 02:35:09
I think I'm missing some basic aspect of ggvis + shiny. Following the tutorials, plots are constructed in server.R using a series of %>% pipes, ending with bind_shiny, which associates the plot with an identifier that can be referred to in ui.R What I don't get though is that the plot itself is not reactive in the way that code within renderTable(), renderText() or reactive() will be. So if I want to refer to an input parameter like input$x in defining the plot, it won't work, I'll get an error saying "Operation not allowed without an active reactive context. (You tried to do something that

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

余生长醉 提交于 2019-12-06 01:22:40
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 app starts to load. Here's the code of my first attempt: ui.R #ui.R library(shiny) library(ggvis)

ggvis - add_legend with multiple data and position legend inside graph

社会主义新天地 提交于 2019-12-05 21:04:47
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) lines(df2$x, df2$y, col = "red") lines(df3$x, df3$y, col = "green") legend("topleft", c("Data 2",

ggVis : creating a plot with multiple layers on different dataset

蹲街弑〆低调 提交于 2019-12-05 20:38:08
问题 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

Rendering ggvis controls in shiny

扶醉桌前 提交于 2019-12-05 13:39:48
I'm having trouble getting an input slider to render in a ggvis plot within a shiny app. The plots render fine without the input slider but after adding it shiny throws this error: Listening on http://xxxxxxxxxxxxxx Error in eval(expr, envir, enclos) : could not find function "compdat" server.R: library(shiny) library(ggvis) data<-data.frame(var1=rnorm(30,5,2.3),var2=rbeta(30,1.5,.8),var3=rnorm(30,10,2.5)) shinyServer(function(input, output,session) { compdat<-reactive({data[, c(input$xInp,input$yInp)]}) vis1 <-reactive({ compdat %>% ggvis(x= ~compdat()[,1],y= ~compdat()[,2]) %>% layer_points