[英]Stop furrr::future_map from printing iteration AFTER finishing
I am using future_map to create several plots where I iterate through a list of variables and output/save a png file per variable to a folder.我正在使用 future_map 创建多个图,在其中迭代变量列表并将每个变量的 png 文件输出/保存到文件夹。 So there is no output that needs to be shown in the console or the "plot" pane.
所以没有需要在控制台或“绘图”窗格中显示的输出。
The plotting part of the function:函数的绘图部分:
ggplot(aes(sample = value,
color = key)) +
stat_qq(alpha = 0.8, size = 0.5) +
theme_light() +
theme(legend.position = "none") +
stat_qq_line() +
facet_wrap(~key,
ncol = 4) +
ggtitle(.var) +
ggsave(filename = here::here(paste0(.path,
.var,
".png")),
units = "cm",
width = 25,
height = 10)}
How I map the function:我如何映射函数:
plan(multiprocess(workers = 10))
future_map(names_list,
~check_dists(df_lips_imputed, .x, "doc/distributions/testing2/"),
verbose = FALSE)
However, after all files are created, I can see they are in the folder, this is slowly printed (takes a while, ~1k iterations):但是,创建完所有文件后,我可以看到它们在文件夹中,这是慢慢打印的(需要一段时间,~1k 次迭代):
[[1]]
[[2]]
[[3]]
...
Does anyone know how to suppress this output?有谁知道如何抑制这个输出?
Many thanks!非常感谢!
If you install the development version of furrr
with如果你安装了开发版的
furrr
devtools::install_github("DavisVaughan/furrr")
You can then use future_walk
, which is acts like walk
does versus map
.然后你可以使用
future_walk
,这就像walk
和map
。 With walk
the function acts by side effects and so the return value is simply the input.使用
walk
函数通过副作用起作用,因此返回值只是输入。
I was having the same issue.我遇到了同样的问题。 I'm not sure if this will change the time that it takes to print out the list elements at the end, but if you save your
future_map
call as a throwaway variable, it will save the output in that variable instead of printing out and clogging up your console or log file:我不确定这是否会改变最后打印出列表元素所需的时间,但是如果您将
future_map
调用保存为一次性变量,它会将输出保存在该变量中,而不是打印出来并阻塞启动您的控制台或日志文件:
x <- future_map(names_list,
~check_dists(df_lips_imputed, .x, "doc/distributions/testing2/"),
verbose = FALSE)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.