There are a large number of CRAN packages that are relevant for economists. The range of finance and econometrics which is now directly feasible in R using existing CRAN libraries is amazing. There is now a concept of CRAN views where R gurus keep track of all the packages out there and tell you which are pertinent for you. Two specific views are of interest, Finance and Econometrics.
In order to get started, you need to do the following steps once:
$ sudo R > install.packages("ctv") > library(ctv) > install.views("Finance") > install.views("Econometrics")
Once you've done this, from here on, in order to stay updated, you must do:
$ sudo R > library(ctv) > update.ctv <- function(view, force.bundles = FALSE) { f <- function(x) if (x[1] == view) x$packagelist$name ctv.pkgs <- unlist( sapply( CRAN.views(), f) ) idx <- if (force.bundles) 1 else c(1,5) installed.pkgs <- c(installed.packages()[,idx]) dnld.packages <- setdiff(ctv.pkgs, installed.pkgs) install.packages(dnld.packages, dependencies = TRUE) update.packages() } > update.ctv("Finance") > update.ctv("Econometrics")
If you are on Mac OS X, you need a slightly different version --
> update.ctv <- function(view, force.bundles = FALSE) { f <- function(x) if (x[1] == view) x$packagelist$name ctv.pkgs <- unlist( sapply( CRAN.views(), f) ) idx <- if (force.bundles) 1 else c(1,5) installed.pkgs <- c(installed.packages()[,idx]) dnld.packages <- setdiff(ctv.pkgs, installed.pkgs) install.packages(dnld.packages, type="source", dependencies = TRUE) update.packages() }
Using update.ctv(), any packages/bundles in the view that are not installed are installed and then all installed packages, not just ones in the view, are updated to their most recent version. When force.bundles is TRUE, this forces reinstallation of all bundles in the view. If any packages in a bundle from a view were manually removed without removing all packages in that bundle then this will be necessary in order to restore the entire bundle. The function update.ctv() is by Gabor Grothendieck and Achim Zeileis.
If you are a serious R user, then subscribing to the mailing lists is strongly recommended. They are freely accessed using your web browser. I am on two of the lists: R-help (Main R Mailing List: Primary help) and R-sig-finance (Special Interest Group for 'R in Finance').
Searching mailing lists is a great tool for finding out stuff, even if you aren't reading them regularly.
Return to R by example
Ajay Shah
ajayshah at mayin dot org