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
--- | |
title: "Benchmarking database queries" | |
author: "Barbara Borges Ribeiro" | |
date: "June 23, 2016" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
library(DBI) |
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
# ------------------------------------------------------------------- | |
# ------------------ REACTIVES INSIDE FOR LOOPS --------------------- | |
# ------------------------------------------------------------------- | |
# ------------------------------------------------------------------- | |
# --- EXAMPLE 1: this works fine, because there are no reactives in - | |
# --- the for lopp -------------------------------------------------- | |
# ------------------------------------------------------------------- | |
library(shiny) |
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
library(shiny) | |
ui <- fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
numericInput("steps", "Time steps:", 10, min=1), | |
actionButton("run", label="Start") | |
), | |
mainPanel( | |
textOutput("status") |
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
# ------------------------------------------------------------------- | |
# ------------------ HIDIND A DATATABLE IN SHINY -------------------- | |
# ------------------------------------------------------------------- | |
# ------------------------------------------------------------------- | |
# --- EXAMPLE 1: this sets the datatable's underlying dataframe to -- | |
# --- NULL, inside a reactive (recalculated whenever a checkbox is -- | |
# --- clicked). While this does result in the datatable disappearing | |
# --- from view, the height does not show --------------------------- |
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
# ------------------------------------------------------------------- | |
# ------------------ PROCESSING DATA MODULARLY---------------------- | |
# ------------------------------------------------------------------- | |
# This app processes some input text through three modules, passing | |
# the result of each module down to the next module. We're also | |
# displaying to the user the (reactive) result of each module, but | |
# usually we'd just be interested in the last one... In those cases, | |
# the modules' ui functions would be empty (except for the last | |
# module, of course). |
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
library(shiny) | |
library(shinyjs) | |
ui <- fluidPage( | |
useShinyjs(), | |
fileInput('inFile', 'Choose file'), | |
actionButton('reset', 'Reset'), | |
tableOutput('tbl') | |
) |
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
# ----------------------------------------------------------------- # | |
# ------------- "Exciting" new features in Shiny 1.0.1 ------------ # | |
# ----------------------------------------------------------------- # | |
library(shiny) | |
# 1. ----------------------------------------------- # | |
# ------------------ reactiveVal() ----------------- # | |
# -------------------------------------------------- # | |
ui <- fluidPage( |
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
library(shiny) | |
countries <- c("Australia", "United Kingdom", "United States") | |
flags <- c( | |
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/au.svg", | |
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/gb.svg", | |
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/us.svg" | |
) |
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
# By default Shiny will always wait for any reactive dependencies to finish (re)calculcating | |
# before displaying the output that depends on them. Without async reactivity in Shiny (which | |
# is not currently available, but it's in the works), it's actually not really possible to | |
# make a reactive dependency be available before it finishes computing. But you can redefine | |
# your reactive so that its output is broken though. | |
# | |
# You can achieve this using reactive values, an observer and invalidateLater(). If this is | |
# new for you, I'd recommend, you read the documentation about invalidateLater(). | |
# | |
# I'll show two simple examples here. For a more elaborate example, see this gist. |
OlderNewer