install_github("ropensci/alm")
library("alm")
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 |
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 |
#' --- | |
#' output: | |
#' word_document | |
#' --- | |
knitr::opts_chunk$set(collapse = TRUE, comment = "#>") | |
#+ | |
library(repurrrsive) | |
library(tidyverse) |
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) |
library(tidyverse) | |
library(repurrrsive) | |
df <- tibble( | |
name = map_chr(got_chars, "name"), | |
titles = map(got_chars, "titles") | |
) | |
df | |
df <- got_chars %>% { |
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 |
httr::GET("http://catfacts-api.appspot.com/api/facts", | |
query = list(number = 5)) %>% | |
httr::content(as = "text", encoding = "UTF-8") %>% | |
jsonlite::fromJSON() |
We set up knitr so it doesn't catch errors, then set | |
`options(error=recover)` to set up R's debug-on-error machinery. | |
We have to do one additional thing, before the options call though: | |
trace the recover function with`sink(NULL)` to turn off the output | |
capturing so the R console is useful when the debugging framework | |
dumps us back into it. This has to happen before the options call | |
because that call grabs the `recover` object and stores it somewhere | |
so setting a trace on recover after the call won't affect the cached | |
version that gets called upon an error. |
#' --- | |
#' output: github_document | |
#' --- | |
#' Worth reminding that `summarise_*()` needs n-to-1 function, `mutate_*()` | |
#' needs n-to-n function? | |
#' | |
#' I can use variable selection helpers from `select()`. Yay! I just didn't | |
#' expect I would need to put them inside of `vars()`. | |
#' |