Created
May 7, 2013 10:40
-
-
Save ramnathv/5531732 to your computer and use it in GitHub Desktop.
rCharts NVD3 Shiny App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(rCharts) | |
shinyServer(function(input, output) { | |
output$myChart <- renderChart({ | |
hair_eye = as.data.frame(HairEyeColor) | |
p6 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == input$gender), | |
type = input$type, dom = 'myChart', width = 800) | |
p6$chart(color = c('brown', 'blue', '#594c26', 'green'), stacked = input$stack) | |
return(p6) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(rCharts) | |
shinyUI(pageWithSidebar( | |
headerPanel("rCharts: Interactive Charts from R | NVD3"), | |
sidebarPanel( | |
selectInput(inputId = "gender", | |
label = "Choose Gender", | |
choices = c("Male", "Female"), | |
selected = "Male"), | |
selectInput(inputId = "type", | |
label = "Choose Chart Type", | |
choices = c("multiBarChart", "multiBarHorizontalChart"), | |
selected = "multiBarChart"), | |
checkboxInput(inputId = "stack", | |
label = strong("Stack Bars?"), | |
value = FALSE) | |
), | |
mainPanel( | |
showOutput("myChart", "nvd3") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having trouble implementing a slightly different example where the nplot is a scatterplot that switches between two variables. The plot doesn't appear even if I remove the switch by replacing
datasetInput()
withMurder
in server.R.Any ideas on how I can make this work?
server.R
ui.R