Instantly share code, notes, and snippets.

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
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)
View lect08.R
library(tidyverse)
library(repurrrsive)
df <- tibble(
name = map_chr(got_chars, "name"),
titles = map(got_chars, "titles")
)
df
df <- got_chars %>% {
View noam.R
library(tidyverse)
(df <- tibble(
x = c(1, NA, 3, NA),
y = c(1, NA, NA, 4),
z = 1:4
))
#> # A tibble: 4 × 3
#> x y z
#> <dbl> <dbl> <int>
#> 1 1 1 1
View alm.md

Install and load alm

install_github("ropensci/alm")
library("alm")
View catfacts.R
httr::GET("http://catfacts-api.appspot.com/api/facts",
query = list(number = 5)) %>%
httr::content(as = "text", encoding = "UTF-8") %>%
jsonlite::fromJSON()