Skip to content

Instantly share code, notes, and snippets.

@edwindj
Created November 8, 2012 22:06
Show Gist options
  • Save edwindj/4042038 to your computer and use it in GitHub Desktop.
Save edwindj/4042038 to your computer and use it in GitHub Desktop.
Shiny tableplot app

Shiny tableplots

This example can be run in R with

if (!require(shiny)){
   library(devtools)
   install_github("shiny", "rstudio")
}

shiny::runGist("4042038")
library(shiny)
library(tabplot)
shinyServer(function(input, output) {
dataset <- reactive(function(){
diamonds
})
output$plot <- reactivePlot(function() {
dat <- dataset()
sortCol <- input$sortCol
decreasing <- input$decreasing
select <- input$select
from <- input$from
to <- input$to
nBins <- max(2,as.numeric(input$nBins), na.rm=TRUE)
tableplot(dat, from=from, to=to, sortCol = sortCol, select_string = select, decreasing = decreasing, nBins=nBins)
})
})
library(shiny)
data(diamonds, package="ggplot2")
dataset <- diamonds
vars <- names(dataset)
shinyUI(pageWithSidebar(
# Application title
headerPanel("Diamonds tableplot"),
sidebarPanel(
selectInput("sortCol", label="Sort on:", choices=vars),
checkboxInput("decreasing", label="Descending", value=FALSE),
numericInput("from", label="from:", value=0, min=0, max=100),
numericInput("to", label="to:", value=100, min=0, max=100),
checkboxGroupInput("select", label="Select columns:", choices=vars, selected=vars),
numericInput("nBins", label="# bin", value=100, min=2, max=500, step=1)
),
mainPanel(
plotOutput("plot", height="800px")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment