Skip to content

Instantly share code, notes, and snippets.

Avatar

Barbara Borges Ribeiro bborgesr

View GitHub Profile
@bborgesr
bborgesr / shiny-insertUI-removable.R
Last active Apr 11, 2019
Uses Shiny's insertUI to create elements (in this example, datatables) at the user's discretion; each of these comes with a button that will remove it from the app (using removeUI).
View shiny-insertUI-removable.R
library(shiny)
ui <- fluidPage(
textInput("divID", "Enter an ID for the custom area:", ""),
helpText("Leave the text input blank for automatically unique IDs."),
actionButton("isrt", "Add a datatable"),
tags$div(id = "placeholder")
)
server <- function(input, output, session) {
rv <- reactiveValues()
@bborgesr
bborgesr / cards-crud-inside-map-inside-buildCards.js
Last active Mar 14, 2019
[Make a CMS card's id unique] Reusing existing code, and keeping in mind that it's preferrable to destructure the object rather than mutate the id in place. #cms
View cards-crud-inside-map-inside-buildCards.js
try {
const card = buildCard(
card,
data,
filtersAndFormatters,
Object.assign({}, settingsAndOptions, { cardIndex })
);
return {...card, id: `${card.id}:${cardIndex}`};
}
@bborgesr
bborgesr / exceptionally-good-presentations.txt
Created Feb 8, 2018 — forked from jmcphers/exceptionally-good-presentations.txt
How to Give an Exceptionally Good Presentation
View exceptionally-good-presentations.txt
"HOW TO GIVE AN EXCEPTIONALLY GOOD PRESENTATION"
CHARACTERS
Joe Cheng.............Moderator
Jennifer Bryan........As Herself
Hadley Wickham........As Himself
Aron Atkins...........Audience
Derrick Kearney.......Audience
@bborgesr
bborgesr / shiny-simple-iterative-printing.R
Created May 5, 2017
Two simple examples of iterative printing in Shiny
View shiny-simple-iterative-printing.R
# 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.
@bborgesr
bborgesr / shiny-1.0.1-new-features.R
Created Mar 30, 2017
"Exciting" new features in Shiny 1.0.1
View shiny-1.0.1-new-features.R
# ----------------------------------------------------------------- #
# ------------- "Exciting" new features in Shiny 1.0.1 ------------ #
# ----------------------------------------------------------------- #
library(shiny)
# 1. ----------------------------------------------- #
# ------------------ reactiveVal() ----------------- #
# -------------------------------------------------- #
ui <- fluidPage(
@bborgesr
bborgesr / iterative-comp-shiny.R
Created Mar 6, 2017
An example of doing prolonged, iterative computation in Shiny. Adapted from: https://gist.github.com/trestletech/8608815
View iterative-comp-shiny.R
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
numericInput("steps", "Time steps:", 10, min=1),
actionButton("run", label="Start")
),
mainPanel(
textOutput("status")
@bborgesr
bborgesr / database-benchmarking.Rmd
Created Jun 23, 2016
Comparing the time that a query takes to run using three different models of database connection: one connection per program/app; one connection per query; using a connection pool.
View database-benchmarking.Rmd
---
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)