Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

R allows us to put code to run in the beginning/end of a session.

What codes would you suggest putting there?

I know of three interesting examples (although I don't have "how to do them" under my fingers here):

  1. Saving the session history when closing R.
  2. Running a fortune() at the beginning of an R session.
  3. I was thinking of having an automated saving of the workspace. But I didn't set on solving the issue of managing space (so there would always be X amount of space used for that backup)

Any more ideas? (or how you implement the above ideas)

p.s: I am not sure if to put this here or on stackoverflow. But I feel the people here are the right ones to ask.

share|improve this question
    
Probably better suited to stackoverflow since it has no particular data analysis relevance. –  Shane Aug 3 '10 at 8:28
    
This question is proposed to be closed. See this meta thread: meta.stats.stackexchange.com/questions/213/… –  user28 Aug 3 '10 at 8:58
1  
I wish we could move a question to Stack Overflow the way you can move a question from Super User... –  JD Long Aug 3 '10 at 20:42
    
I moved it manually to stackoverflow. JD - I agree with you. –  Tal Galili Aug 4 '10 at 20:14
    
Following on from meta.stats.stackexchange.com/questions/252/… I've reopened this question. –  csgillespie Aug 11 '10 at 10:43

2 Answers 2

Some information about how to implement this is provided at help(.First) and help(.Last).

share|improve this answer

On open, I set R options, load environment variables (eg. global variables, API keys) and open database connections, and then close those connections when exiting. With some of these things, I prefer to do them onLoad of my packages rather than per session.

Regarding how to save your session, use the save command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.