Skip to content

Instantly share code, notes, and snippets.

View J-O-H-N-P-A-U-L's full-sized avatar

JOHNPAUL J-O-H-N-P-A-U-L

View GitHub Profile
@jcheng5
jcheng5 / promise-api-2.md
Last active January 8, 2019 16:55
Promise API, Part 2: Promise Domains

Promise Domains

(This is a departure from Promises/A+ spec. It's needed to support the use of promises with Shiny, especially reactivity, but also seems like it'd be useful for logging, profiling, error handling...)

There are some places in R and in Shiny especially, where it's very useful to set up changes to the environment temporarily, execute some user-provided code, and then change the environment back to its original state.

For one example, consider the capture.output function. This won't work:

capture.output({
@MarkEdmondson1234
MarkEdmondson1234 / dynamicSelectShinyModule.R
Last active November 21, 2020 00:09
Shiny modules for creating dynamic SelectInputs
library(shiny)
#' Safe subset
#'
#' @param df Dataframe
#' @param column One name of column to subset within
#' @param subset Vector of entries in column to subset to
#'
#' If column not in df, returns back the df
safeSubset <- function(df, column, subset){