Commit 965132d3 authored by Marco De Lucia's avatar Marco De Lucia
Browse files

Trying and fix the package load

parent 9eb709c1
......@@ -2,7 +2,7 @@
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2018
### Janis Jatnieks, janisj@gfz-potsdam.de, jatnieks@janis.es
### Time-stamp: "Last modified 2018-05-06 23:23:15 delucia"
### Time-stamp: "Last modified 2018-05-07 00:06:19 delucia"
### Licence: LGPL version 2.1
## resolve dependencies automatically
......@@ -24,7 +24,7 @@ start_up <- function(session_path=FALSE, ## to disable set to a non-string
## testing
"cluster","stringr","gtools", #"ftsa",
"amap"),
install=FALSE,
install=TRUE,
use_cores=4)
{
gc()
......@@ -36,22 +36,24 @@ start_up <- function(session_path=FALSE, ## to disable set to a non-string
## load session data first
if (class(session_path)[1]=="character" & file.exists(session_path) ) {
cat("Loading...",session_path)
msg("Loading...",session_path)
load(session_path, .GlobalEnv)
cat(" OK!\n")
msg(" OK")
}
## loading the right data is important!
## check install and load neccessary packages
cat("Checking for required packages...\n")
msg("Checking for required packages...")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) {
cat("Need to install these packages:",new.packages,"\n")
if (install) {
install.packages(new.packages)
libpath <- readline(prompt="Please specify the absolute path where the packages will be installed (e.g., '~/Rdevel'): \n")
cat(" Afterwards, remember to store this path somewhere for R to find it again, such as R_LIBS_USER='~/Rdevel' in ~/.Renviron\n")
install.packages(new.packages, lib=libpath)
}
} else cat("Package checks OK!\n")
} else msg("Package checks OK!")
loadsuccess <- lapply(list.of.packages, require, character.only=TRUE)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment