我怎样才能让 R 的输出更详细,以便让我放心它还没有坏?

J. *_*ini 5 memory r verbosity

我经常运行占用大量 RAM 的代码,并且可能需要长达一个小时才能提供输出。通常,我会花半个小时来运行这样的代码,而且我会担心会出现问题。有什么办法可以让 R 向我保证还没有任何错误?我想我可以将里程碑放在代码本身中,但我想知道 R(或 RStudio)中是否有任何东西可以在运行时自动完成这项工作。例如,查看代码使用了多少内存会很方便,因为只要我看到内存使用量显着变化,我就会放心它仍在工作。

Moo*_*per 5

You might like my package {boomer}.

If you rig() your function, all its calls will be exploded and printed as the code is executed.

For instance

# remotes::install_github("moodymudskipper/boomer")
fun <- function(x) {
  x <- x + 1
  Sys.sleep(3)
  x + 1
}

library(boomer)

# rig() the function and all the calls will be exploded
# and displayed as they're run
rig(fun)(2)
Run Code Online (Sandbox Code Playgroud)

例子