This file contains hidden or 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(tidyverse) | |
keep_top_n <- function(df, col, n = 10) { | |
semi_join(df, head(count_(df, col, sort = TRUE), n)) | |
} | |
data(mpg) | |
# All car models | |
mpg %>% nrow() | |
# Just car models of top three manufacturers |
This file contains hidden or 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(rvest) | |
html_more_nodes <- function(session, css, more_css) { | |
xml2:::xml_nodeset(c( | |
html_nodes(session, css), | |
tryCatch({ | |
html_more_nodes(follow_link(session, css = more_css), | |
css, more_css) | |
}, error = function(e) NULL) | |
)) |
This file contains hidden or 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(tidyverse) | |
library(magrittr) | |
library(stringr) | |
library(readxl) | |
directory <- "bunch/of/excel/files" | |
# Get an overview of all the Excel files and their sheets | |
sheets <- | |
data_frame(file = list.files(directory, full.names = TRUE), |
This file contains hidden or 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
#!/usr/bin/env RScript | |
messages <- purrr::map_chr(devtools::test(), | |
list("results", 1, "message")) | |
q("no", status = sum(messages != "success")) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import json | |
import string | |
prefix_key = "b" # My prefix key in tmux is Ctrl-B | |
prefix_hex = "02" # The hex code that iTerm sends (corresponds to Ctrl-B) | |
keys_upper = string.ascii_uppercase + r'!@#$%^&*()_+{}:"|<>?~' | |
keys_lower = string.ascii_lowercase + r"1234567890-=[];'\,./`" |
OlderNewer