Mercurial > repos > petr-novak > repeatrxplorer
comparison checkR.R @ 0:1d1b9e1b2e2f draft
Uploaded
author | petr-novak |
---|---|
date | Thu, 19 Dec 2019 10:24:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1d1b9e1b2e2f |
---|---|
1 #!/usr/bin/env Rscript | |
2 rfiles = dir(path = "lib", pattern ="[.]R$", full.names = TRUE, recursive = TRUE) | |
3 rcode = grep('library', unlist(sapply(rfiles, readLines)), value = TRUE) | |
4 | |
5 packages = unique(gsub("[),].*$","", gsub("^.*library[(]","",rcode))) | |
6 packages = c(packages, "Rserve") # Rserve added - it is loaded from python | |
7 versions = list('igraph'="1.0.0") | |
8 for (i in packages){ | |
9 missing_packages=c() | |
10 packgs = installed.packages() | |
11 tryCatch( | |
12 { | |
13 suppressPackageStartupMessages(library(i, character.only = TRUE)) | |
14 message(paste("package ",i,"succesfuly loaded")) | |
15 if( !is.null(versions[[i]])){ | |
16 if (numeric_version(versions[[i]])>numeric_version(packgs[i,"Version"])){ | |
17 message(paste("\033[0;31mversion",packgs[i,"Version"], | |
18 "of package ",i,"is installed but at least ", | |
19 numeric_version(versions[[i]]),"is needed! \033[0m")) | |
20 } | |
21 } | |
22 }, | |
23 error=function(cond){ | |
24 message(paste('\033[0;31mpackage ',i, | |
25 'was not loaded \033[0m - please install this package!')); | |
26 missing_packages = c(missing_packages,i) | |
27 } | |
28 ) | |
29 } | |
30 | |
31 |