我想重命名一个组split中的R标记列表。每个数据帧在列表中都有自己的名称。我的问题是,我想使用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发布于 2021-05-30 01:38:36
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")))https://stackoverflow.com/questions/67753908
复制相似问题