Skip to content

Instantly share code, notes, and snippets.

@jjallaire
jjallaire / dygraphs.Rmd
Created October 28, 2014 11:49
htmlwidgets and runtime: shiny
---
title: "Dygraphs in R Markdown"
output: html_document
runtime: shiny
---
```{r}
library(dygraphs)
hw <- HoltWinters(ldeaths)
@jjallaire
jjallaire / Presentation.Rmd
Created August 1, 2014 10:29
revealjs_presentation with self_contained: false
---
title: "Untitled"
output:
revealjs_presentation:
theme: serif
self_contained: false
incremental: true
transition: none
pandoc_args: ["--css", "style.css"]
---
@jjallaire
jjallaire / justgage.R
Created April 6, 2014 14:08
justgage
#' @export
justgage <- function(title, value, min, max,
label = NULL, width = 200, height = 160) {
structure(class = "justgage", list(
title = title,
label = label,
value = value,
min = min,
max = max,
@jjallaire
jjallaire / server.R
Created December 18, 2013 13:08
Shiny Example 07_widgets
library(shiny)
library(datasets)
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
# Return the requested dataset
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
@jjallaire
jjallaire / server.R
Created December 18, 2013 13:07
Shiny Example 06_tabsets
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# Reactive expression to generate the requested distribution. This is
# called whenever the inputs change. The output functions defined
# below then all use the value computed from this expression
data <- reactive({
dist <- switch(input$dist,
@jjallaire
jjallaire / server.R
Created December 18, 2013 13:06
Shiny Example 05_sliders
library(shiny)
# Define server logic for slider examples
shinyServer(function(input, output) {
# Reactive expression to compose a data frame containing all of the values
sliderValues <- reactive({
# Compose data frame
data.frame(
@jjallaire
jjallaire / server.R
Created December 18, 2013 13:04
Shiny Example 04_mpg
library(shiny)
library(datasets)
# 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"))
@jjallaire
jjallaire / server.R
Created December 18, 2013 13:03
Shiny Example 03_reactivity
library(shiny)
library(datasets)
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
# By declaring databaseInput as a reactive expression we ensure that:
#
# 1) It is only called when the inputs it depends on changes
# 2) The computation and result are shared by all the callers (it
@jjallaire
jjallaire / server.R
Created December 18, 2013 12:57
Shiny Example 02_text
library(shiny)
library(datasets)
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
# Return the requested dataset
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
@jjallaire
jjallaire / server.R
Created December 18, 2013 12:55
Shiny Example 01_hello
library(shiny)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
# Expression that generates a plot of the distribution. The expression
# is wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change