R语言的清屏命令

Python09

R语言的清屏命令,第1张

命令代码参考如下:

# 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、首先在R中,plot函数作图时会自动给出xy轴的刻度标度

2、然后有时需要自己定义xy轴的刻度,这时可以用axis中的at和labels参数来更改,先令plot不要画出xy轴的标度

3、最后,用axis函数设置xy轴的刻度,这样问题就解决了。