library(shiny) | |
library(ggplot2) | |
function(input, output) { | |
dataset <- reactive({ | |
diamonds[sample(nrow(diamonds), input$sampleSize),] | |
}) | |
output$plot <- renderPlot({ | |
p <- ggplot(dataset(), aes_string(x=input$x, y=input$y)) + geom_point() | |
if (input$color != 'None') | |
p <- p + aes_string(color=input$color) | |
facets <- paste(input$facet_row, '~', input$facet_col) | |
if (facets != '. ~ .') | |
p <- p + facet_grid(facets) | |
if (input$jitter) | |
p <- p + geom_jitter() | |
if (input$smooth) | |
p <- p + geom_smooth() | |
print(p) | |
}, height=700) | |
} |
library(shiny) | |
library(ggplot2) | |
dataset <- diamonds | |
pageWithSidebar( | |
headerPanel("Diamonds Explorer"), | |
sidebarPanel( | |
sliderInput('sampleSize', 'Sample Size', min=1, max=nrow(dataset), | |
value=min(1000, nrow(dataset)), step=500, round=0), | |
selectInput('x', 'X', names(dataset)), | |
selectInput('y', 'Y', names(dataset), names(dataset)[[2]]), | |
selectInput('color', 'Color', c('None', names(dataset))), | |
checkboxInput('jitter', 'Jitter'), | |
checkboxInput('smooth', 'Smooth'), | |
selectInput('facet_row', 'Facet Row', c(None='.', names(dataset))), | |
selectInput('facet_col', 'Facet Column', c(None='.', names(dataset))) | |
), | |
mainPanel( | |
plotOutput('plot') | |
) | |
) |
This comment has been minimized.
This comment has been minimized.
Impressive once I figured out which facet variable would be interesting to choose. For example X = price, Y=carat, Color=color, Facet Row = cut, Facet Column = clarity. runApp() gives a warning: "Passing functions to 'reactive' is deprecated. Please use expressions instead." ?reactive doesn't talk about a replacement function. How would you update server.R to fix this deprecated function? |
This comment has been minimized.
This comment has been minimized.
@paul4forest: Fixed, thanks. You stop passing in a real function and just pass in an expression. So |
This comment has been minimized.
This comment has been minimized.
@ramsdgp:
|
This comment has been minimized.
This comment has been minimized.
Hi. This fails for me with |
This comment has been minimized.
This comment has been minimized.
Hi guys, I have a problem of building web apps with R using googleVis on shiny. My OS system is MacbookPro and I use RStudio. I updated GoogleVis to 0.56 version as well as shiny. Error:
This is same error msg as the one I got two days ago when I tried to run GoogleVis and shiny together. Thanks for your time on reading and help. |
This comment has been minimized.
This comment has been minimized.
For some reason, my app does not like printing both ggplot and qplot with the same function. Does qplot() have some different print command I'm not aware of? |
This comment has been minimized.
This comment has been minimized.
Nevermind. Found I had another bug. Print command works FINE for both. |
This comment has been minimized.
This comment has been minimized.
I am getting an error:
|
This comment has been minimized.
what is the source of the data set, can i access that.
dataset <- reactive(function() {
diamonds[sample(nrow(diamonds), input$sampleSize),]
})