Mercurial > repos > petr-novak > repeatrxplorer
diff checkR.R @ 0:1d1b9e1b2e2f draft
Uploaded
author | petr-novak |
---|---|
date | Thu, 19 Dec 2019 10:24:45 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/checkR.R Thu Dec 19 10:24:45 2019 -0500 @@ -0,0 +1,31 @@ +#!/usr/bin/env Rscript +rfiles = dir(path = "lib", pattern ="[.]R$", full.names = TRUE, recursive = TRUE) +rcode = grep('library', unlist(sapply(rfiles, readLines)), value = TRUE) + +packages = unique(gsub("[),].*$","", gsub("^.*library[(]","",rcode))) +packages = c(packages, "Rserve") # Rserve added - it is loaded from python +versions = list('igraph'="1.0.0") +for (i in packages){ + missing_packages=c() + packgs = installed.packages() + tryCatch( + { + suppressPackageStartupMessages(library(i, character.only = TRUE)) + message(paste("package ",i,"succesfuly loaded")) + if( !is.null(versions[[i]])){ + if (numeric_version(versions[[i]])>numeric_version(packgs[i,"Version"])){ + message(paste("\033[0;31mversion",packgs[i,"Version"], + "of package ",i,"is installed but at least ", + numeric_version(versions[[i]]),"is needed! \033[0m")) + } + } + }, + error=function(cond){ + message(paste('\033[0;31mpackage ',i, + 'was not loaded \033[0m - please install this package!')); + missing_packages = c(missing_packages,i) + } + ) +} + +