在 R 中,plot() 在 R 中打开一个新窗口并显示图形。
有没有一种方法可以对表执行相同的操作 - 无需打印到命令行?
我的意思不是 print()、head() 或 sink() 到文件。
这将很有用,因为人们可以将表格转移到单独的窗口,而不会弄乱控制台。
vprint <- function(x, ...) {
require(htmltools)
html_print(pre(paste0(capture.output(print(x, ...)), collapse="\n")))
}
vcat <- function(...) {
require(htmltools)
html_print(pre(paste0(capture.output(cat(...)), collapse="\n")))
}
vprint(mtcars)
vcat(str(mtcars))
Run Code Online (Sandbox Code Playgroud)