Checking around seems there's no a detail description on how to add your frequent-using-packages as your default loadings in R. Here is an easy way to make it (as least works for MAC OS).
By launching R you will see this message:
----------------------------------------------------------------
...
[R.app GUI 1.61 (6492) x86_64-apple-darwin10.8.0]
[Workspace restored from /Users/dz2t/.RData]
[History restored from /Users/dz2t/.Rapp.history]
>
----------------------------------------------------------------
Here, the directory ''/Users/dz2t/" is the HOME folder that R will search and run when it's initiating. To load a set of default stuffs (not only packages), what you need to do is just to create a ".Rprofile" file in this directory. I use the mac terminal to create this file and I guess you can also use any text editor to do so and save it under an exact name: .Rprofile. And finally the most important and also a easy thing next to do is to list the libraries in the file and save it like that:
----------------------------------------------------------------
options(width=65, digits=5)
options(defaultPackages=c(getOption("defaultPackages"), "ggplot2", "mice", "grid", "gtools",
"gdata", "pscl", "zoo", "car", "DirichletReg", "plyr", "bestglm", "tree",
"betareg", "psych", "gee", "ggdendro", "sas7bdat", "reshape2"))
s <- base::summary
h <- utils::head
n <- base::names
.First<-function() cat("\n Welcome to R!\n\n")
.Last<-function() cat("\n See you next time! \n\n")
----------------------------------------------------------------
where s <- base::summary is a shortcut for summary(), which means you can put anything you want in this file and R will load and run it before your start work.
No comments:
Post a Comment