在 purrr 和 makeDataReport() 中使用 map() 重命名多个 R Markdown

Rename multiple R Markdowns using map() in purrr and makeDataReport()

我想重命名分组拆分中的 R Markdowns 列表。每个数据框在列表中都有自己的名称。我的问题是我想使用 makeDataReport() 为每个组拆分生成一个 R Markdown 报告,但是该函数在重命名新的 R Markdown 输出时给我一个错误。

library(palmerpenguins)
library(dataReporter)
split(penguins, penguins$island) %>% 
  map(makeDataReport)

Data report generation is finished. Please wait while your output file is being rendered.
Error in .f(.x[[i]], ...) : 
  The file name(s) to be used by dataReporter, dataReporter_.x__i__.Rmd and dataReporter_.x__i__.pdf, is(are) already in use. We recommend trying one of the following solutions: 
 - rename your dataReporter output file using the "file" option 
 - Add a volume number to your file name using the "vol" option 
 - check that you do not want to keep the original file and if so, use makeDataReport() with argument replace = TRUE

makeDataReport 中有一个参数,我可以更改输出 R Markdown 名称 makeDataReport(dataframe, file = "Torgersen.Rmd") 。但我如何以动态方式进行 - 有效地重命名所有这些?

预期输出:

Torgersen.Rmd
Biscoe.Rmd
Dream.Rmd
pengiuns <- split(penguins, penguins$island) 
pengiuns %>% 
  map(~makeDataReport(., file = paste0(unique(.$island),".Rmd")))

#编辑以使用名称而不是列

pengiunsList <- split(penguins, penguins$island) 
pengiunsList %>% 
  map2(names(pengiunsList), ~makeDataReport(.x, file = paste0(.y,".Rmd")))

#Edit2: 直到现在我才知道的第三种解决方案

pengiunsList <- split(penguins, penguins$island) 
pengiunsList %>% 
  imap(~makeDataReport(.x, file = paste0(.y,".Rmd")))