
390
21
章
R
マークダウン
reports <- tibble(
class = unique(mpg$class),
filename = stringr::str_c("fuel-economy-", class, ".html"),
params = purrr::map(class, ~ list(my_class = .))
)
reports
#> # A tibble: 7
×
3
#> class filename params
#> <chr> <chr> <list>
#> 1 compact fuel-economy-compact.html <list [1]>
#> 2 midsize fuel-economy-midsize.html <list [1]>
#> 3 suv fu
el-economy-suv.html <list [1]>
#> 4 2seater fuel-economy-2seater.html <list [1]>
#> 5 minivan fuel-economy-minivan.html <list [1]>
#> 6 pickup fuel-economy-pickup.html <list [1]>
#> # ... with 1 more rows
次に、
render()
の引数名と列名のマッチをとり、
purrr
の並列ウォークを使って各列で一度に
render()
を呼び出します。
reports %>%
select(output_file = ...