识别影响者

使用 purrr 的函数式编程进阶

Colin Fay

Data Scientist at ThinkR

map_at()

在特定位置使用 map_at()

my_list <- list(
  a = 1:10, 
  b = 1:100, 
  c = 12)
map_at(.x = my_list, .at = "b", .f = sum)
$a
 [1]  1  2  3  4  5  6  7  8  9 10

$b
[1] 5050

$c
[1] 12
使用 purrr 的函数式编程进阶

negate()

谓词取反:

not_character <- negate(is.character)
my_list <- list(
  a = 1:10, 
  b = "a", 
  c = iris)
map(my_list, not_character)
$a
[1] TRUE

$b
[1] FALSE

$c
[1] TRUE
使用 purrr 的函数式编程进阶

开始练习!

使用 purrr 的函数式编程进阶

Preparing Video For Download...