副詞の結果を扱う

purrr で学ぶ中級関数型プログラミング

Colin Fay

Data Scientist & R Hacker at ThinkR

安全な結果のクレンジング

transpose() で結果を変換:

# 転置は n 個の要素 a と b のリストを、
# a と b それぞれが n 個の要素を持つリストに変える
l <- list("a", 2, 3)
map(l, safe_log) %>% length()
3
map(l, safe_log) %>% transpose() %>% length()
2
purrr で学ぶ中級関数型プログラミング

compact() について

compact()NULL を削除します:

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

[[2]]
[1] 3

[[3]]
[1] 4
purrr で学ぶ中級関数型プログラミング

possibly() と 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
purrr で学ぶ中級関数型プログラミング

httr 入門

purrr で学ぶ中級関数型プログラミング

Let's practice!

purrr で学ぶ中級関数型プログラミング

Preparing Video For Download...