Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check when R session have been started?

Tags:

r

Is there way to check when R session have been started ? In interactive mode, not necessary in batch mode.

like image 718
Qbik Avatar asked May 23 '16 11:05

Qbik


3 Answers

It won't work on the current sessions, but may (locally) work on future sessions. Edit/create a .Rprofile file in your home directory and add these two lines:

.startedTime<-Sys.time()
.sessionTime<-function() Sys.time()-.startedTime

The lines in .Rprofile are executed at the beginning of the session. I choose names starting with a dot so they don't get returned by ls(). Next, start an R session and when you give:

.sessionTime()

it will return the elapsed time from the beginning of the session.

like image 68
nicola Avatar answered Oct 13 '22 16:10

nicola


The proc.time function track times since R started (see help) which could be used as:

Sys.time() - proc.time()["elapsed"]

to find out when session started.

like image 29
Marek Avatar answered Oct 13 '22 16:10

Marek


In windows you can try to see time of creation temp dir for r-session

file.info(tempdir())$ctime

Its only idea and may be not always work

like image 5
Batanichek Avatar answered Oct 13 '22 18:10

Batanichek