Mercurial > repos > petrn > repeatexplorer
view checkR.R @ 6:2925751ed586 draft
Uploaded
author | petrn |
---|---|
date | Fri, 20 Dec 2019 12:59:39 +0000 |
parents | f6ebec6e235e |
children |
line wrap: on
line source
#!/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) } ) }