Wednesday, November 14, 2012

My way of upgrading R

There's one task that I hate to do in R … INSTALL A NEW VERSION!

With a couple of new releases coming out every year, it's easy to become outdated.

R 2.15.2 has recently been released and this time I decided to do some research on how to easily upgrade R installations.

Packages

Over the years the number of packages I use regularly has grown and I like to keep them whenever I upgrade R.

That's how I do it nowadays.

#----------------------------------------------------------------------------
# execute on CURRENT system
#----------------------------------------------------------------------------

# get list of installed packages
packages <- subset(as.data.frame(installed.packages()),
                   !Priority %in% c("base", "recommended"),
                   select = c(Package))

# and save it
save(packages,
     file=paste(R.Version()$version.string, "packages.Rdata", sep=' '))
Then I install the new version of R and there I do the following.

#----------------------------------------------------------------------------
# upgrade R and
# execute on NEW system
#----------------------------------------------------------------------------

# load list of additional packages
load("R version 2.15.0 (2012-03-30) packages.Rdata")

# and install them
install.packages(packages$Package, dependencies = TRUE)
As can be seen I already had missed the last upgrade :).

Sunday, July 29, 2012

Puppy Linux : How to create an ISO image from a CD

Put CD into the optical drive but don’t mount it.

Open a terminal screen (console).

Just to be on the safe side, verify if it is mounted or not with the mount command.

sh-4.1# mount

If CD  is reported as mounted (maybe it was automatically by the OS), use the umount command.

sh-4.1# umount /dev/sr0

or

sh-4.1# umount /mnt/sr0

Create the ISO image with the dd command.

sh-4.1# dd if=/dev/sr0 of=/mnt/home/image.iso

Where,
  • if=/dev/sr0 : Read from /dev/sr0 (raw format)
  • of=/mnt/home/image.iso : write to a file named image.iso

Friday, March 23, 2012

SQLite : a database for actuarial work

While searching for an alternative to the limit of 2 gigabytes of Microsoft Access, I found SQLite (http://www.sqlite.org/) a small software library (350KB) in C without external dependencies that implements a SQL database engine.

The source code for SQLite is 
in the public domain and supports multi platform databases up to 2 terabytes.

The simplicity of SQLite is comes from acting directly on a single file (a database) on the hard disk, not requiring installation, configuration or administration. Performing a backup boils down to copy the file to another location.

Another added advantage is its direct connection to the R (http://www.r-project.org) using the RSQLite library.

Sunday, March 18, 2012

An R script template

This is the my current way of starting a new R script.

The main purpose of this template is to reduce the human intervention in running the R script in another computer.

So it goes through the following steps:
  • work folder creation
  • folder tree creation
  • install and load needed packages