Skip to content

Instantly share code, notes, and snippets.

Jennifer (Jenny) Bryan jennybc

Block or report user

Report or block jennybc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TIOBE redux
Exerting my will over the gist name
@jennybc
jennybc / vv_transformer.R
Last active Aug 9, 2019
A glue transformer inspired by the "variables & values" f-string syntax in Python 3.8
View vv_transformer.R
library(glue)
vv_transformer <- function(text, envir) {
regex <- "=$"
if (!grepl(regex, text)) {
return(identity_transformer(text, envir))
}
text <- sub(regex, "", text)
res <- identity_transformer(text, envir)
n <- length(res)
@jennybc
jennybc / get-function-signatures_reprex.R
Last active Mar 31, 2019
List all function signatures in a package
View get-function-signatures_reprex.R
library(tidyverse)
## attach the package whose function signatures you want to examine
library(usethis)
x <- lsf.str(pos = "package:usethis")
## inspired by examining print.ls_str and head.function
get_signatures <- function(x) {
x %>%
set_names() %>%
View curl commands
curl 'https://sheets.googleapis.com/v4/spreadsheets/1eP_0mb67k0MD9BBEZ5gv7jsyFzcTvMbrr3uGTG1GXZk?includeGridData=true&ranges=Sheet1!A1%3AG6&key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_get_3.json
curl 'https://sheets.googleapis.com/v4/spreadsheets/1eP_0mb67k0MD9BBEZ5gv7jsyFzcTvMbrr3uGTG1GXZk/values/Sheet1!A1%3AG6?key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_values_get_3.json
View curl commands
curl 'https://sheets.googleapis.com/v4/spreadsheets/132Ij_8ggTKVLnLqCOM3ima6mV9F8rmY7HEcR-5hjWoQ?includeGridData=true&ranges=Sheet1!A1%3AF6&key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_get_2.json
curl 'https://sheets.googleapis.com/v4/spreadsheets/132Ij_8ggTKVLnLqCOM3ima6mV9F8rmY7HEcR-5hjWoQ/values/Sheet1!A1%3AF6?key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_values_get.json
View curl commands
curl 'https://sheets.googleapis.com/v4/spreadsheets/1BzfL0kZUz1TsI5zxJF1WNF01IxvC67FbOJUiiGMZ_mQ?includeGridData=true&ranges=Africa!A1%3AF3&key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_get.json
curl 'https://sheets.googleapis.com/v4/spreadsheets/1BzfL0kZUz1TsI5zxJF1WNF01IxvC67FbOJUiiGMZ_mQ/values/Africa!A1%3AF3?key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_values_get.json
View pmap-and-map2-also-useful.R
library(tidyverse)
## approximates big_df in the post
big_df <- mtcars %>%
select(cyl, mpg, disp) %>%
arrange(cyl) %>%
slice(17:22) %>%
rename(ID = cyl)
## dummy function that needs access to ID and data
@jennybc
jennybc / 2018-02_game-of-thrones-rectangling.R
Last active Apr 28, 2018
Live code that goes with Data Rectangling talk
View 2018-02_game-of-thrones-rectangling.R
#' ---
#' output:
#' word_document
#' ---
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
#+
library(repurrrsive)
library(tidyverse)
View day01.R
library(testthat)
rev_captcha <- function(x) {
x <- as.integer(strsplit(x, "")[[1]])
xd <- diff(c(x, x[1]))
sum(x[xd == 0])
}
expect_equal(rev_captcha("1122"), 3)
expect_equal(rev_captcha("1111"), 4)
@jennybc
jennybc / lect08.R
Created Nov 8, 2017
lect08_prompts
View lect08.R
library(tidyverse)
library(repurrrsive)
df <- tibble(
name = map_chr(got_chars, "name"),
titles = map(got_chars, "titles")
)
df
df <- got_chars %>% {
You can’t perform that action at this time.