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
rm(list = ls()) | |
library(tidyverse) | |
library(estimatr) | |
N <- 1000 | |
dat <- | |
data.frame( | |
Y = rnorm(N), |
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
# The below demonstrates the madness of R's treatment of NA values. | |
# Some examples taken from https://stackoverflow.com/questions/25100974/na-matches-na-but-is-not-equal-to-na-why/25101796 | |
# Logical examples | |
NA %in% NA | |
# [1] TRUE | |
NA == NA |
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
# ttable: a grammar of tables | |
# https://gist.github.com/leeper/f9cfbe6bd185763762e126a4d8d7c286 | |
# aggregate/summarize | |
# arrange | |
# annotation (metadata features) | |
# theme |
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
variables: | |
CODECOV_TOKEN: "CODECOV_TOKEN_STRING" | |
_R_CHECK_CRAN_INCOMING_: "false" | |
_R_CHECK_FORCE_SUGGESTS_: "true" | |
APT_PKGS: "libcurl4-openssl-dev libssh2-1-dev libssl-dev libxml2-dev zlib1g-dev git" | |
before_script: | |
- apt-get update | |
- apt-get install -y --no-install-recommends ${APT_PKGS} | |
- apt-get install -y --no-install-recommends qpdf pandoc pandoc-citeproc |
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
## http://polygraph.cool/films/ | |
## https://github.com/matthewfdaniels/scripts | |
x <- "https://raw.githubusercontent.com/matthewfdaniels/scripts/master/data/character_list5.csv" | |
characters <- read.csv(x, na.strings = c("NULL", "?"), | |
fileEncoding = "ISO-8859-1", stringsAsFactors = FALSE) | |
## some ages are clearly (negative) birth years ... oops | |
characters$age[!is.na(characters$age) & characters$age < 0] <- NA | |
characters$age[!is.na(characters$age) & characters$age > 105] <- NA |
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(inline) | |
library(stringi) | |
#' Replace a substring of a string | |
#' | |
#' @param str string the source string that you want to replace characters in | |
#' (a character vector of length 1) | |
#' @param repl another string (this will be copied into \code{str}) | |
#' @param pos position of the first character to be replaced | |
#' @param len number of characters to replace (if the string is shorter, |
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
#!/bin/bash | |
# AUTHOR: Bob Rudis <[email protected]> (@hrbrmstr) | |
# LICENSE: MIT + file zLICENSE | |
TODAY=`date +%Y-%m-%d` | |
TODAY_MD=`date +%B\ %d,\ %Y` | |
YEAR=`date +%Y` | |
PACKAGENAME=$1 |
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
# The UNF algorithm provides a clearly defined specification for creating a data hash. | |
# The algorithm has many strengths, including the fact that it is file format-independent, | |
# controls for floating point and rounding errors, and is independent of the column- | |
# organization of a dataset (i.e., variable order is irrelevant). | |
# | |
# A weakness, however, is that UNF is row-order sensitive. This is useful in terms of | |
# data subsetting (i.e., a subset of a dataset produces a different UNF than the full | |
# dataset), but it produces a weakness when two identical datasets are arranged in | |
# different row orders. Here's a simple example: |
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
ghelp <- function(topic, in_cran=TRUE) { | |
require(htmltools) # for getting HTML to the viewer | |
require(rvest) # for scraping & munging HTML | |
# github search URL base | |
base_ext_url <- "https://github.com/search?utf8=%%E2%%9C%%93&q=%s+extension%%3AR" | |
ext_url <- sprintf(base_ext_url, topic) | |
# if searching with user:cran (the default) add that to the URL |
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(httr) | |
library(jsonlite) | |
library(base64enc) | |
#---------------------------------------- | |
# Functions to access RemoteControl API | |
#---------------------------------------- | |
get_session_key <- function(username, password) { | |
body.json = list(method = "get_session_key", | |
id = 1, |
NewerOlder