Umgang mit Adverb-Ergebnissen

Fortgeschrittene funktionale Programmierung mit purrr

Colin Fay

Data Scientist & R Hacker at ThinkR

Ergebnisse sicher bereinigen

Transformiere das Ergebnis mit transpose():

# transpose wandelt eine Liste mit n Elementen a und b
# in eine Liste von a und b, jeweils mit n Elementen
l <- list("a", 2, 3)
map(l, safe_log) %>% length()
3
map(l, safe_log) %>% transpose() %>% length()
2
Fortgeschrittene funktionale Programmierung mit purrr

Über compact()

compact() entfernt NULL:

list(1, NULL, 3, 4, NULL) %>%
  compact()
[[1]]
[1] 1

[[2]]
[1] 3

[[3]]
[1] 4
Fortgeschrittene funktionale Programmierung mit purrr

possibly() und compact()

otherwise = NULL %>% compact():

l <- list(1,2,3,"a")
possible_log <- possibly(log, otherwise = NULL)
map(l, possible_log) %>% compact()
[[1]]
[1] 0

[[2]]
[1] 0.6931472

[[3]]
[1] 1.098612
Fortgeschrittene funktionale Programmierung mit purrr

Ein sanfter Einstieg in httr

Fortgeschrittene funktionale Programmierung mit purrr

Lass uns üben!

Fortgeschrittene funktionale Programmierung mit purrr

Preparing Video For Download...