0

I'm trying to customize my R setup. I understood the part where we can put our functions(.First/Last) in Rprofile.site or .Rprofile. but I want to take .Rdata route. As I understand that if I have a .First/.Last function in any of the .R file in my working directory. Then when I open my .Rdata file my custom setting should be loaded.

Though I get an Adios when I quit the session but I don't get anything when I open my .Rdata. Anyway, below are my .First and .Last function.

.First <- function() {
options(prompt="$ ", continue="+\t")  # $ is the prompt
options(digits=5, length=999)
cat(paste(date(),"\nWelcome\n"))
# custom numbers and printout
x11()                                 # for graphics
par(pch = "+")   
# my personal functions
library(cluster)                      # attach a package
s <- base::summary
h <- utils::head
n <- base::names
}


.Last <- function() {
graphics.off()                        # a small safety measure.
cat(paste(date(),"\nAdios\n"))        # Is it time for lunch?
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Chirayu Chamoli
  • 2,076
  • 1
  • 17
  • 32
  • 2
    Why do you want to "take .Rdata route"? – Dason Jul 18 '15 at 20:26
  • @Dason i can manipulate .Rdata in any directory but i can change .Rprofile only once. – Chirayu Chamoli Jul 19 '15 at 02:54
  • You're confused. Just modify `~/.Rprofile` as explained in `help(Startup)`. – Dirk Eddelbuettel Jul 26 '15 at 03:44
  • @DirkEddelbuettel: Can we do it the .Rdata way? Also i wanted to ask if we define a .First function in our R project, would that be similar to making changes in .Rprofile. – Chirayu Chamoli Jul 26 '15 at 04:01
  • @DirkEddelbuettel: sorry for the trouble. But i have read that doc so many times, though im not able to clearly understand it. A line from the doc " A function .First (and .Last) can be defined in appropriate ‘.Rprofile’ or ‘Rprofile.site’ files or have been saved in ‘.RData’ ". So i think we could define it, but am not able to work around. Thanks for your inputs. – Chirayu Chamoli Jul 26 '15 at 04:12
  • Dason, using the .Rdata route, you can treat it as an executable. – MadmanLee Jul 17 '20 at 15:03

0 Answers0