Skip to content

Instantly share code, notes, and snippets.

View gadenbuie's full-sized avatar

Garrick Aden-Buie gadenbuie

View GitHub Profile
write.csv(iris, "iris.csv")

read_csv_filtered <- function(file, ..., select_vars = NULL, chunk_size = 10) {
  stopifnot(requireNamespace("dplyr", quietly = TRUE),
            requireNamespace("readr", quietly = TRUE))
  
  filter_by_id <- function(..., select_vars) {
    function(.data, pos) {
      if (!is.null(select_vars)) .data <- dplyr::select(.data, !!!select_vars)
@gadenbuie
gadenbuie / index.Rmd
Last active August 28, 2019 21:38
xaringan slides on repeat
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, Inc."
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
includes:
#! /usr/bin/env Rscript
'usage:
create.R project <path>
create.R package <path>
create.R golem <path>
create.R gh <repo_spec> <path>
options:
<path> Path for creating project or package
@gadenbuie
gadenbuie / bus_times.md
Created September 24, 2019 19:33
bus times delay plot
library(tidyverse)

sample_csv <- c(
  "sequence;lieu;prevu;reel", "1;UdeS;16:42;16:44", "2;;16:50;16:51", 
  "3;;16:55;16:55", "4;;16:59;16:58", "5;Gt-US;17:01;17:03", "6;;17:03;17:04", 
  "7;;17:05;17:05", "8;;17:06;17:06", "9;;17:12;17:10", "10;;17:13;17:11", 
  "11;Gt-McM;17:16;17:14", "12;;17:17;17:17", "13;;17:19;17:19", 
  "14;Bel-MM;17:22;17:24", "15;;17:25;17:26", "16;;17:27;17:27", 
  "17;Csherb;17:28;17:28", "18;;17:29;17:29", "19;Kg-Bel;17:32;17:30", 
@gadenbuie
gadenbuie / app.R
Created December 30, 2019 20:22
dynamic Shiny input names
library(shiny)
library(purrr)
ui <- fluidPage(
textInput("inputId", "inputId", value = "number"),
helpText("Create a new input ID for the dropdown below"),
selectInput("number", "Renamable", choices = letters[1:5], selected = 1),
helpText("Notice that old inputs stick around..."),
verbatimTextOutput("debug"),
tags$script(HTML(
@gadenbuie
gadenbuie / app.R
Last active December 31, 2019 23:02
drag and drop a new element
library(shiny)
library(purrr)
ui <- fluidPage(
tags$head(
tags$link(rel = "//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"),
tags$script(src = "https://code.jquery.com/ui/1.12.1/jquery-ui.js"),
tags$link(href = "style.css", rel = "stylesheet")
),
fluidRow(
@gadenbuie
gadenbuie / app.R
Created January 6, 2020 19:53
A midly convoluted example of shared inputs between modules
library(shiny)
# Here's a simple text module that with one text input and that shows a local result
textModUI <- function(id, label = "Word") {
ns <- NS(id)
tagList(
textInput(ns("word"), label),
verbatimTextOutput(ns("result"))
)
}
library(shiny)
commits <- purrr::map_dfr(
git2r::commits(reverse = TRUE),
~ tibble::tibble(
sha = .x$sha,
subject = gsub("\n.*", "", .x$message),
message = .x$message
)
)
@gadenbuie
gadenbuie / module_typingStats.R
Last active January 17, 2020 20:33
A module for the #js4shiny workshop
typingStatsUI <- function(id) {
ns <- NS(id)
tagList(
fluidRow(
div(
class = "col-xs-12 col-sm-9 col-md-6",
uiOutput(ns("prompt"))
),
div(
class = "col-xs-12 col-sm-3 col-md-6",