Skip to content

Instantly share code, notes, and snippets.

View sckott's full-sized avatar
😸

Scott Chamberlain sckott

😸
View GitHub Profile
library(cli)
library(rlang)
assert1 <- function(x, y, arg = caller_arg(x)) {
  if (!inherits(x, y)) {
    abort(format_error("{.strong {arg}} must be of class {y}"))
 }
@sckott
sckott / privileges.R
Last active October 16, 2024 22:44
Privileges with dbplyr/dplyr
library(DBI)
library(RPostgres)
library(dplyr)
library(dbplyr)
con <- dbConnect(Postgres())
dbExecute(con, "CREATE ROLE admin")
dbExecute(con, "CREATE ROLE alice")
@sckott
sckott / safeerror.R
Last active February 26, 2024 23:10
safeError behavior in observeEvent vs. eventReactive
library(shiny)
library(bslib)
library(ggplot2)
ui <- page_sidebar(
title = h1(
class = "bslib-page-title",
"Errors when bins == 29"
),

The function modified

multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL, 
                      labs=list(), labpos=list(c(0.5,0.03), c(0.03,0.5))) {
  require(grid)
  
  # Make a list from the ... arguments and plotlist
  plots <- c(list(...), plotlist)
  
@sckott
sckott / visualizations_tutorial.R
Created September 30, 2011 15:47
Tutorial on basic visualizations in R
#######################################################
#### Created by Rolf Lohaus, EEB Dept., Rice University
####
#### Part of the code modified and extended from
#### Robert I. Kabacoff's Quick-R website
#### (http://www.statmethods.net)
#######################################################
############### HIGH-LEVEL PLOTTING FUNCTIONS ###############
@sckott
sckott / stuff.md
Created October 11, 2022 01:35
gist gist gist

Stuff and things

head of mtcars

head(mtcars)
@sckott
sckott / stuff.md
Created October 11, 2022 01:34
gist gist gist

Stuff and things

head of mtcars

head(mtcars)
@sckott
sckott / stuff.md
Created October 11, 2022 01:33
gist gist gist

Stuff and things

head of mtcars

head(mtcars)
@sckott
sckott / stuff.md
Created October 11, 2022 01:33
gist gist gist

Stuff and things

head of mtcars

head(mtcars)
@sckott
sckott / stuff.md
Created October 11, 2022 01:27
gist gist gist

Stuff and things

head of mtcars

head(mtcars)