Skip to content

Instantly share code, notes, and snippets.

@cryoguy
cryoguy / server.R
Created November 12, 2016 22:24
R Shiny Stuff
library("shiny")
library("datasets")
library("ggplot2")
#from here http://web.stanford.edu/~cengel/cgi-bin/anthrospace/building-my-first-shiny-application-with-ggplot
# We tweak the "am" field to have nicer factor labels. Since this doesn't
# rely on any user inputs we can do this once at startup and then use the
# value throughout the lifetime of the application
mpgData <- mtcars
mpgData$am <- factor(mpgData$am, labels = c("Automatic", "Manual"))
@cryoguy
cryoguy / ui.R
Created November 12, 2016 22:27
library(shiny)
# Define UI for miles per gallon application
shinyUI(pageWithSidebar(
# Application title
headerPanel("Miles Per Gallon"),
# Sidebar with controls to select the variable to plot against mpg
# and to specify whether outliers should be included