## install RandomFields_3.0.26.tar.gz from ## http://ms.math.uni-mannheim.de/de/publications/software/ ## ## The command install() below may help installing the package install <- function(version="3.0.26", pkg="RandomFields", www = "http://ms.math.uni-mannheim.de/uploads/media", lib) { lib="~/TMP" notinstalled <- class(try(silent=TRUE, library(pkg, lib=lib, character.only=TRUE))) == "try-error" if (!notinstalled) { pkges <- installed.packages(lib.loc=lib) split <- as.integer(unlist(strsplit(version, "\\."))) splitInst <- as.integer(unlist(strsplit(pkges[which(pkges [, 1] == pkg)[1], "Version"], "\\."))) version.ok <- !any(instless <- splitInst < split) if (!version.ok) { pos <- which(instless)[1] version.ok <- any(split[1:pos] > splitInst[1:pos])# pos not (pos - 1) ! ## otherwise 1:0 appears } version.ok <- pkges[which(pkges [, 1] == pkg)[1], "Version"] >= version if (!version.ok) { pkgname <- paste("package", sep=":", pkg) do.call("detach", list(name=pkgname)) cat("Version", pkges[which(pkges [, 1] == pkg)[1], "Version"], "of 'RandomFields' is is installed, but version", version, "is needed.\n") } } else cat("'RandomFields' is not installed yet.\n") if (notinstalled || !version.ok) { ##several of the following lines are taken from the INLA installation source if (.Platform$OS.type == "windows") { suff <- "zip" tp <- "win.binary" } else { suff <- "tar.gz" tp <- "source" } fullname <- paste(pkg, "_", version, ".", suff, sep="") dfile <- paste(tempdir(), .Platform$file.sep, fullname, sep="") sfile <- paste(www, "/", fullname, sep="") download.file(sfile, dfile) install.packages(dfile, lib = lib, repos=NULL, type = tp) remove.file(dfile) library(pkg, lib=lib) } } install() ## as super user # install(lib="") ## as usual user