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

lunedì 26 novembre 2007

This is one of that tiny function that help you to save yourself a lot of time! I thank the list for the suggestion!

library(gdata)
?keep
data(women, cars)
keep(cars)
## To remove all objects except cars, run:
## keep(cars, sure=TRUE)

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.