Running R via terminal in Windows and leaving R session open

假装没事ソ 提交于 2019-12-06 09:59:54

Add this to your .Rprofile:

STARTUP_FILE <- Sys.getenv("STARTUP_FILE")
if (file.exsts(STARTUP_FILE)) source(STARTUP_FILE) 

and then set the indicated environment variable outside of R and then run R. e.g. from the Windows cmd line:

set STARTUP_FILE=C:\test.R
R
... R session ...
q()

Variations

There are many variations of this. For example, we could make a copy of the .Rprofile file in a specific directory such as ~/test, say, and add this code to that copy

source("~/test/test.R")

in which case R would only run test.R if R were started in that directory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!