Table of Contents
R repository
I have created a repository for my R packages as described in the section 6.6 of R Installation and Administration manual. You can install or download any of my packages directly from R and, moreover, have them automatically updated.
It contains source and Windows binary distributions. Windows versions may not be up to date as I have a limited possibilities to build Windows binary versions right now.
Browsing
The repository can now be browsed, just go to http://bojan.3e.pl/R. The directory structure follows CRAN standard.
Sources of the packages in their current versions can be found in the src/contrib
directory. Older version are in the src/contrib/Archive
.
Windows binaries are in subdirectories of bin/windows/contrib
. The subdirectories correspond to the R versions.
There is also hacks
subdirectory which contains modified versions of some of the packages written by others.
Downloading and installing
With a repository like mine you can download and/or install packages directly from R. You can either download a source or binary distribution without installation or directly install a package.
To download a package without installation you use the download.packages
function:
# to download the sources only download.packages("bojan", destdir="c:/R", repos="http://bojan.3e.pl/R", type="source") # to download the binary version for windows download.packages("bojan", destdir="c:/R", repos="http://bojan.3e.pl/R", type="win.binary")
The argument destdir
is the location where the file will be saved.
To install any of my packages directly you use a install.packages
function with appropriate arguments pointing to my repository. For example to install package bojan you need to type:
install.packages( "bojan", repos="http://bojan.3e.pl/R")
Package bojan
will be downloaded and installed to the default library tree. The default location is the one on the first position in the vector returned by .LibPaths()
. If there are no additional library trees defined the default location is $RHOME/library
. You may change it with lib
argument.
Automatic updating
Another feature of using the repository is the possibility for automatic updating. With small addition to your personal configuration file R will automatically check my server for newer versions of any of my packages you have installed.
We need to create a user copy of Rprofile
file in your user directory. Under Windows system user directory probably is defined as c:\documents and settings\userName\my documents
. If you are not sure open R and type Sys.getenv(“R_USER”)
. This will return the appropriate path.
If there is no copy of Rprofile
in your user directory yet create it by copying the Rprofile
file from $RHOME/etc
.
Now edit this file and add the following lines:
local({ r <- getOption("repos") r["bojan"] <- "http://bojan.3e.pl/R" options(repos=r) })
This basically adds my repository to the list of places in which R looks for packages if instructed to install or update a package.
Now if, on Windows, you go to menu “Packages | Install package(s)…” the list will include my packages as well. Also, if you use update.packages
then R will also look on my server for newer versions.