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.
great stuff! Extremely useful, thanksa lot !
RispondiEliminawhy not simply press ctr+l? does the same job
RispondiEliminaIn a Unix terminal CTRL+l cleans the screen. In the default GUI for Mac it doesn't work! The depicted solution does work more generally.
RispondiEliminaI'm a mac/pc user but I do all my r in pc so im not sure if this will work but try command l
RispondiEliminaControl+L works well under RGui and Windows.
RispondiEliminacommand + alt + l should work on a Mac.
RispondiEliminaThank you!
EliminaHi,
RispondiEliminathose function don't work anymore on Windows 7 with R 2.15
do you have an updated version?
Dear Stephen, thanks for your feedback. Unfortunately I don't own a Windows 7 license and I currently use either Linux or Mac OS X. To make it short, I don't have an updated version of this tip. If you find a working solution to this task(maybe via StackOverflow) please let me know so I can update the 'recipe'. Thank you!
RispondiElimina