Thursday, March 12, 2009

R operators

x + y
x - y
x * y
x / y
x ^ y
x %% y
x %/% y

> 4 %% 2
[1] 0
> 4 %% 2
[1] 0
> 4 %/% 2
[1] 2
> 5 %/% 2
[1] 2

Saturday, March 7, 2009

r: clear screen

# 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

from http://onertipaday.blogspot.com/2007/05/how-to-clear-screen-in-r.html,
cool!