class: center, middle ![:scale 30%](/assets/images/coding_club_logo_1.png) # 24 SEPTEMBER 2020 ## INBO coding club Somewhere over the rainbow --- class: center, middle ![:scale 100%](/assets/images/20200924/20200924_remote_R_learners.jpg)
Source: [stats-illustrations](https://github.com/allisonhorst/stats-illustrations) of [Allison Horst](https://github.com/allisonhorst/)
--- class: center, middle ![:scale 90%](/assets/images/20200924/20200924_badge_strings.png) --- class: center, middle ![:scale 100%](/assets/images/20200924/20200924_string_theory.jpg)
No string theory today!
--- class: center, middle ![:scale 100%](/assets/images/20200924/20200924_strings_intro.png)
We will focus on the tidyverse package `stringr`
--- class: center, middle ![:scale 90%](/assets/images/20200924/20200924_stringr_cheatsheet.png) [Download cheatsheet here](https://github.com/inbo/coding-club/blob/master/cheat_sheets/20180426_cheat_sheet_stringr.pdf) --- class: center, middle ### How to get started? Check the [Each session setup](https://inbo.github.io/coding-club/gettingstarted.html#each-session-setup) to get started. ### First time coding club? Check the [First time setup](https://inbo.github.io/coding-club/gettingstarted.html#first-time-setup) section to setup. --- class: left, middle ![:scale 100%](/assets/images/coding_club_sticky_concept.png)
No yellow sticky notes online :-( We use hackmd (see next slide) but basic principle doesn't change. --- class: center, middle ### Share your code during the coding session! Go to https://hackmd.io/3YGdtGAsQ1G9ahAg4YODRQ?both
--- class: left, middle # Download data and code Today instead of downloading the files manually, we will test a new inborutils function called `setup_codingclub_session()`. Restart your R session and update the inborutils package by running: ```r if (!"remotes" %in% rownames(installed.packages())) { install.packages("remotes") } remotes::install_github("inbo/inborutils") ``` To download the coding club material of today, just run `setup_codingclub_session()`. For a past date, use the "YYYYMMDD" format, e.g. `setup_codingclub_session("20200825")` to download the coding club material of last session on August, 25. For all options, check the [documentation online](https://inbo.github.io/inborutils/reference/setup_codingclub_session.html). You can of course download [data](https://github.com/inbo/coding-club/blob/master/data/20200924/20200924_bird_rings.tsv) and [scripts](https://github.com/inbo/coding-club/blob/master/src/20200924/20200924_challenges.R) manually* still as we always did!
* __Note__: check the getting started instructions on [how to download a single file](https://inbo.github.io/coding-club/gettingstarted.html#each-session-setup)
--- background-image: url(/assets/images/background_challenge_1.png) class: left, middle # Challenge 1 1. Find birds with a 6 characters long metal ring (column `metal_ring`) and a color ring (column `color_ring`) starting with a C and ending with a R 2. All color rings should be uppercase. Find anomalies 3. Solve all anomalies found in (2) by setting all color rings uppercase --- background-image: url(/assets/images/background_challenge_2.png) class: left, middle # Challenge 2 1. Create a new column called `color_ring_complete` containing color ring information in this format: `background_color`+`inscription_color`+`"("`+`color_ring`+`")"`, e.g. RW(FJAC) 2. We have to extract all color rings (column `color_ring`) with a **4-letter only** long inscription where the third letter is an A. --- class: center, middle ## Intermezzo: the power of regex *regex* what?? REGular EXpresssions ``` example_string <- "I. love. the. 2019(!!) INBO. Coding. Club! Session. of. 24/09/2020...." ``` Go to page 2 of the cheat sheet ![:scale 70%](/assets/images/20200924/20200924_stringr_cheatsheet_regex.png) --- background-image: url(/assets/images/background_challenge_3.png) class: left, middle # Challenge 3 1. The dots in color rings (column `color_ring_dots`), e.g. `KRO.C`, `KZ.AC`, are used for improving readibility. Apart from that, the values in column `color_ring_dots` should be exactly the same as the ones in column `color_ring`. Find anomalies. 2. Some metal rings (column `metal_ring`) start with one or more asterisks. Remove the asterisks. 3. Find color rings (column `color_ring`) containing two consecutive vowels --- class: left, middle # Bonus challenge 1. Now that you removed the asteriks from metal rings, you can map metal rings following the [EURING Exchange Code 2000+ standard](https://euring.org/files/documents/EURING2000%2BCodev112.pdf). A ring number should consist of up to ten alphanumeric characters. At page 7 we read: > *Where the ring number consist of fewer than ten numbers/letters, the number is padded with dots. These dots are always inserted to the left of the rightmost row of numbers.*
Examples: `H146416` → `H...146416`, `H67169` → `H....67169` 2. As we are all speaking about vaccines: https://dodona.ugent.be/en/activities/303251929/ ([Dutch version available](https://dodona.ugent.be/nl/activities/303251929/)). Use `variable <- readline()` to read a line from the terminal and assign it to `variable`. --- class: left, middle ## Resources - Solutions are available in R file: [`src/20200924/20200924_challenges_commented_solutions.R`](https://github.com/inbo/coding-club/blob/master/src/20200924/20200924_challenges_commented_solutions.R) - Video recording of the coding club session is available on [INBO's vimeo channel](https://vimeo.com/463832080) - R specific regex tester: https://spannbaueradam.shinyapps.io/r_regex_tester/ (e.g. "\\\\." for finding dots) - general regext tester: https://regex101.com/ (but pay attention: "\\" instead of R typic double backslash "\\\\") - Did you know you can analyse text with R? Take a look at: [tidy text mining](https://www.tidytextmining.com/) --- class: center, middle ![:scale 30%](/assets/images/coding_club_logo_1.png) Room: online
Date: __27/10/2020__, van 10:00 tot 12:00
Subject: Dates in R (registration announced via DG_useR@inbo.be)