R语言的清屏命令

R语言的清屏命令是什么?类似于dos的cls的命令

命令代码参考如下:

# An R function to clear the screen on RGui:
cls <- function() {
if (.Platform$GUI[1] != "Rgui")
return(invisible(FALSE))
if (!require(rcom, quietly = TRUE)) # Not shown any way!
stop("Package rcom is required for 'cls()'")
wsh <- comCreateObject("Wscript.Shell")
if (is.null(wsh)) {
return(invisible(FALSE))
} else {
comInvoke(wsh, "SendKeys", "\014")
return(invisible(TRUE))
}
}
#cls() # test
# If you want to make sure that it worked (well, not 100% sure, but...)
res <- cls()
if (res) cat("Console should be cleared now!\n")
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-08-29
Ctrl + L 清屏
或者菜单栏的 编辑 > 清空控制台本回答被提问者和网友采纳