我知道如何使用R会话期间添加时间戳
R> h <- taskCallbackManager()
R> h$add(function(expr, value, ok, visible) {
+ options("prompt"=format(Sys.time(), "%H:%M:%S> "));
+ return(TRUE) },
+ name = "simpleHandler")
[1] "simpleHandler"
07:25:42> a <- 2
如this answer所述。
我怎样才能使这个永久性功能,以便RStudio始终将此作为提示?
一种选择是在.Rprofile
中有一个~/
文件(通常在Windows中为“C:/ Users / me / Documents”),并在其中添加以下内容。只要您在控制台上执行某些操作,它就会显示时间。
.First <- function(){
h <- taskCallbackManager()
h$add(function(expr, value, ok, visible) {
options("prompt"=format(Sys.time(), "%H:%M:%S> "));
return(TRUE) }, name = "simpleHandler")
}
我想你也可以在你的“C:\ Program Files \ R \ R-x.x.x \ etc”中的Rprofile.site
中做到这一点。正如@ r2evans所指出的,这似乎是一个坏主意。