So I've had a play around and it won't be possible to do what I am trying. The function install.packages
reloads your .Rprofile when it is called. For example if I do the following:
Create temporary .Rprofile:
cat(".Rprofile loaded!\n")
Load R:
R version 3.0.0 (2013-04-03) -- "Masked Marvel"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin12.3.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
.Rprofile loaded
> install.packages("ade4")
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.ms.unimelb.edu.au/src/contrib/ade4_1.5-2.tar.gz'
Content type 'application/x-tar' length 1375680 bytes (1.3 Mb)
opened URL
==================================================
downloaded 1.3 Mb
.Rprofile loaded
Showing that the .Rprofile is read in again at package installation.
While the process of package mirroring can't be automated in this way, the function can still be left in the .Rprofile, and called manually by the user.