├── .gitignore ├── .nojekyll ├── LICENSE ├── README.html ├── README.md ├── _site.yml ├── about.Rmd ├── about.html ├── bk00_vectors-and-lists.Rmd ├── bk00_vectors-and-lists.html ├── bk01_base-functions.Rmd ├── bk01_base-functions.html ├── by-nc.png ├── ex20_bulk-gmail.Rmd ├── ex20_bulk-gmail.html ├── ex22_github-issues-pull-requests.Rmd ├── ex22_github-issues-pull-requests.html ├── ex24_xml-wrangling.Rmd ├── ex24_xml-wrangling.html ├── ex26_ny-food-market-json.Rmd ├── ex26_ny-food-market-json.html ├── foodMarkets ├── nys.dbf ├── nys.prj ├── nys.sbn ├── nys.sbx ├── nys.shp ├── nys.shp.xml ├── nys.shx └── retail_food_markets.json ├── footer.html ├── index.Rmd ├── index.html ├── ls00_inspect-explore.Rmd ├── ls00_inspect-explore.html ├── ls01_map-name-position-shortcuts.Rmd ├── ls01_map-name-position-shortcuts.html ├── ls02_map-extraction-advanced.Rmd ├── ls02_map-extraction-advanced.html ├── ls03_map-function-syntax.Rmd ├── ls03_map-function-syntax.html ├── ls08_trump-tweets.Rmd ├── ls08_trump-tweets.html ├── ls08_trump-tweets_cache └── html │ ├── __packages │ ├── unnamed-chunk-30_aaaed2621e0089d001dc8d28f1bd1b10.RData │ ├── unnamed-chunk-30_aaaed2621e0089d001dc8d28f1bd1b10.rdb │ └── unnamed-chunk-30_aaaed2621e0089d001dc8d28f1bd1b10.rdx ├── ls12_different-sized-samples.Rmd ├── ls12_different-sized-samples.html ├── ls13_list-columns.Rmd ├── ls13_list-columns.html ├── ls13_list-columns_files └── figure-html │ ├── unnamed-chunk-22-1.png │ └── unnamed-chunk-23-1.png ├── more-resources.Rmd ├── more-resources.html ├── pt00_gotchas.Rmd ├── pt00_gotchas.html ├── purrr-slides-trump-tweets.png ├── purrr-tutorial.Rproj ├── site_libs ├── bootstrap-3.3.5 │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── cerulean.min.css │ │ ├── cosmo.min.css │ │ ├── darkly.min.css │ │ ├── flatly.min.css │ │ ├── fonts │ │ │ ├── Lato.ttf │ │ │ ├── LatoBold.ttf │ │ │ ├── LatoItalic.ttf │ │ │ ├── NewsCycle.ttf │ │ │ ├── NewsCycleBold.ttf │ │ │ ├── OpenSans.ttf │ │ │ ├── OpenSansBold.ttf │ │ │ ├── OpenSansBoldItalic.ttf │ │ │ ├── OpenSansItalic.ttf │ │ │ ├── OpenSansLight.ttf │ │ │ ├── OpenSansLightItalic.ttf │ │ │ ├── Raleway.ttf │ │ │ ├── RalewayBold.ttf │ │ │ ├── Roboto.ttf │ │ │ ├── RobotoBold.ttf │ │ │ ├── RobotoLight.ttf │ │ │ ├── RobotoMedium.ttf │ │ │ ├── SourceSansPro.ttf │ │ │ ├── SourceSansProBold.ttf │ │ │ ├── SourceSansProItalic.ttf │ │ │ ├── SourceSansProLight.ttf │ │ │ └── Ubuntu.ttf │ │ ├── journal.min.css │ │ ├── lumen.min.css │ │ ├── paper.min.css │ │ ├── readable.min.css │ │ ├── sandstone.min.css │ │ ├── simplex.min.css │ │ ├── spacelab.min.css │ │ ├── united.min.css │ │ └── yeti.min.css │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── npm.js │ └── shim │ │ ├── html5shiv.min.js │ │ └── respond.min.js ├── font-awesome-5.1.0 │ ├── css │ │ ├── all.css │ │ └── v4-shims.css │ └── webfonts │ │ ├── fa-brands-400.eot │ │ ├── fa-brands-400.svg │ │ ├── fa-brands-400.ttf │ │ ├── fa-brands-400.woff │ │ ├── fa-brands-400.woff2 │ │ ├── fa-regular-400.eot │ │ ├── fa-regular-400.svg │ │ ├── fa-regular-400.ttf │ │ ├── fa-regular-400.woff │ │ ├── fa-regular-400.woff2 │ │ ├── fa-solid-900.eot │ │ ├── fa-solid-900.svg │ │ ├── fa-solid-900.ttf │ │ ├── fa-solid-900.woff │ │ └── fa-solid-900.woff2 ├── highlightjs-9.12.0 │ ├── default.css │ ├── highlight.js │ └── textmate.css ├── htmlwidgets-1.2 │ └── htmlwidgets.js ├── htmlwidgets-1.3 │ └── htmlwidgets.js ├── jquery-1.11.3 │ └── jquery.min.js ├── jqueryui-1.11.4 │ ├── README │ ├── images │ │ ├── ui-icons_444444_256x240.png │ │ ├── ui-icons_555555_256x240.png │ │ ├── ui-icons_777620_256x240.png │ │ ├── ui-icons_777777_256x240.png │ │ ├── ui-icons_cc0000_256x240.png │ │ └── ui-icons_ffffff_256x240.png │ ├── index.html │ ├── jquery-ui.css │ ├── jquery-ui.js │ ├── jquery-ui.min.css │ ├── jquery-ui.min.js │ ├── jquery-ui.structure.css │ ├── jquery-ui.structure.min.css │ ├── jquery-ui.theme.css │ └── jquery-ui.theme.min.css ├── jsonedit-binding-2.0.0 │ ├── core-js │ │ ├── LICENSE │ │ ├── dist │ │ │ └── shim.min.js │ │ └── package.json │ ├── jsonedit.js │ ├── jsonedit.yaml │ ├── jsoneditor │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── README.md │ │ └── dist │ │ │ ├── img │ │ │ ├── jsoneditor-icons.png │ │ │ └── jsoneditor-icons.svg │ │ │ ├── jsoneditor.min.css │ │ │ └── jsoneditor.min.js │ ├── reactjson.js │ ├── reactjson.yaml │ └── reactjson │ │ ├── LICENSE │ │ ├── README.md │ │ ├── dist │ │ └── main.js │ │ └── package.json ├── jsonedit-binding-2.1.0 │ └── jsonedit.js ├── jsoneditor-5.25.6 │ ├── img │ │ ├── jsoneditor-icons.png │ │ └── jsoneditor-icons.svg │ ├── jsoneditor.min.css │ └── jsoneditor.min.js ├── jsoneditor-5.5.5 │ ├── img │ │ ├── jsoneditor-icons.png │ │ └── jsoneditor-icons.svg │ ├── jsoneditor.min.css │ └── jsoneditor.min.js ├── navigation-1.1 │ ├── codefolding.js │ ├── sourceembed.js │ └── tabsets.js └── tocify-1.9.1 │ ├── jquery.tocify.css │ └── jquery.tocify.js ├── talks.Rmd ├── talks.html ├── talks ├── 2018-09_latinr │ ├── .gitignore │ ├── 00_purrr-motivation.R │ ├── 01_list-exploration.R │ ├── 02_basic-map-workflow.R │ ├── 03_gapminder-walk-map-dfrow.R │ ├── 99_pipe.R │ └── README.md ├── earl-examples.R ├── got-pov.R ├── ice.rds ├── trump-tweets-setup.R ├── trump-tweets.R └── trump-tweets.csv └── trump_tweets_df.rda /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | purrr-slides.key 5 | purrr-slides.pdf 6 | ideas.R 7 | json-to-tibble.Rmd 8 | memory_lane.R 9 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/purrr-tutorial/c3c5c2ab7fcbb5021ea6503465da722aec260dde/.nojekyll -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | https://creativecommons.org/licenses/by-nc/4.0/ 2 | -------------------------------------------------------------------------------- /README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |Source for an R Markdown website for learning how to use purrr:
308 | 309 |Will be based on:
303 |https://github.com/jennybc/send-email-with-r#readme
304 |Overview:
305 |purrr
come in?
319 | pmap(edat, mime)
to create one MIME-formatted email object per row/emailsafely(gmailr::send_message)
to create a “safe” version of the function that send messages … so one failure doesn’t derail thingsmap(email, safe_send_message)
to send the emailtranspose()
and map_lgl()
to inspect message success vs failureIn the meantime, here’s the clean script that is developed there:
327 |suppressPackageStartupMessages(library(gmailr))
328 | suppressPackageStartupMessages(library(dplyr))
329 | suppressPackageStartupMessages(library(purrr))
330 | library(readr)
331 |
332 | addresses <- read_csv("addresses.csv")
333 | marks <- read_csv("marks.csv")
334 | my_dat <- left_join(marks, addresses)
335 |
336 | this_hw <- "The Fellowship Of The Ring"
337 | email_sender <- 'Peter Jackson <peter@tolkien.example.org>' # your Gmail address
338 | optional_bcc <- 'Anonymous <anon@palantir.example.org>' # for me, TA address
339 | body <- "Hi, %s.
340 |
341 | Your mark for %s is %s.
342 |
343 | Thanks for participating in this film!
344 | "
345 |
346 | edat <- my_dat %>%
347 | mutate(
348 | To = sprintf('%s <%s>', name, email),
349 | Bcc = optional_bcc,
350 | From = email_sender,
351 | Subject = sprintf('Mark for %s', this_hw),
352 | body = sprintf(body, name, this_hw, mark)) %>%
353 | select(To, Bcc, From, Subject, body)
354 | edat
355 | write_csv(edat, "composed-emails.csv")
356 |
357 | emails <- edat %>%
358 | map_n(mime)
359 |
360 | ## optional: use if you've created your own client id
361 | use_secret_file("gmailr-tutorial.json")
362 |
363 | safe_send_message <- safely(send_message)
364 | sent_mail <- emails %>%
365 | map(safe_send_message)
366 |
367 | saveRDS(sent_mail,
368 | paste(gsub("\\s+", "_", this_hw), "sent-emails.rds", sep = "_"))
369 |
370 | errors <- sent_mail %>%
371 | transpose() %>%
372 | .$error %>%
373 | map_lgl(Negate(is.null))
374 | sent_mail[errors]
375 |
376 |
377 |
378 |
379 |
380 | Will be based on:
303 |https://github.com/jennybc/analyze-github-stuff-with-r#readme
304 |Overview:
305 |gh
packagemap()
is used to iterate over repomap_*()
functions used to create data frame from nested listmap()
to iterate over PRs and get affected files from the diffunnest()
to go from one row per PR to one row per file modified in a PRmap_*()
functions used to create data frame from nested listmap()
to iterate over issues and retrieve follow up commentswalk()
unnest()
to go from one row per issue to one row per comment on an issueSeveral clean scripts are there, as well as expository README.
333 | 334 | 335 | 336 | 337 | 338 |Will be based on:
303 |https://github.com/jennybc/manipulate-xml-with-purrr-dplyr-tidyr#readme
304 |Overview:
305 |map()
on that list with more XPath to retain only nodes from gsx
namespace
313 | map()
at depth 2 to extract sub-node names and textunnest()
to go from one row per Sheet row to one row per Sheet cellmap()
: extract elements name and position shortcuts, type-specific and simplifying mapThis work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
342 |