Manipuler des URL

Programmation fonctionnelle intermédiaire avec purrr

Colin Fay

Data Scientist & R Hacker at ThinkR

Créer des mappers

as_mapper()

library(purrr)
mult <- as_mapper(~ .x * 2)
map(list(airquality, mtcars), 
    mult)
[[1]]
    Ozone Solar.R Wind Temp Month Day
1      82     380 14.8  134    10   2
2      72     236 16.0  144    10   4
3      24     298 25.2  148    10   6
4      36     626 23.0  124    10   8
5      NA      NA 28.6  112    10  10
6      56      NA 29.8  132    10  12
... 
Programmation fonctionnelle intermédiaire avec purrr

stringr::str_detect()

Détection de motifs :

library(stringr)
lyrics <- c("Is this the real life?", 
            "Is this just fantasy?", 
            "Caught in a landslide", 
            "No escape from reality")
str_detect(lyrics, "life")
TRUE FALSE FALSE FALSE
Programmation fonctionnelle intermédiaire avec purrr

Note sur les booléens

Sommer des booléens :

sum(FALSE, TRUE, TRUE, FALSE, TRUE)
3
Programmation fonctionnelle intermédiaire avec purrr

Passons à la pratique !

Programmation fonctionnelle intermédiaire avec purrr

Preparing Video For Download...