Visualizzazione post con etichetta screen. Mostra tutti i post
Visualizzazione post con etichetta screen. Mostra tutti i post

domenica 6 maggio 2007

How to clear screen in R (Windows)

This tip (taken from this old thread) does work only under Windows:

cls <- function() {
       require(rcom)
       wsh <- comCreateObject("Wscript.Shell")
       comInvoke(wsh, "SendKeys", "\014")
       invisible(wsh)
}
cls()
or
# 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()

See this StackOverflow Question for other solutions.