R/chmi.dirs.R

Defines functions chmi.required_packages chmi.phendir

#-------------------
# load directories
#-------------------

#' @export
chmi.phendir <- function()
{
  nodename <- Sys.info()[["nodename"]]

  switch(nodename,
			'crp1028.csc.es' = '/Users/migvazquez/Documents/Datasets/chmi',
      'CRP1028.local' = '/Users/migvazquez/Documents/Datasets/chmi',
      'annamiquel-H110M-S2H' = '/home/annamiquel/Datasets/chmi',
      'annamiquel-Aspire-E5-571' = '/home/annamiquel/Datasets/chmi',
      'LAPTOP-UJDSJL8E' = '~/Datasets/chmi',

    stop(paste0("`nodemname` (", nodename, ") is unknown")))
}



#---------------
# load packages
#---------------

chmi.required_packages <- function()
{
	### repositories
	local({r <- getOption('repos')
  	r['CRAN'] <- 'https://cloud.r-project.org/'
  	options(repos = r)})

	### funtion to auto_load
	auto_load <- function(a.package){
		suppressWarnings(suppressPackageStartupMessages(
  	library(a.package, character.only = T)))
	}

	### list of packages
	auto_packages <- c('tidyverse', 'lubridate', 'data.table',
		'testthat', 'assertthat', 'plyr', 'dplyr', 'Hmisc', 'reshape',
		'viridis', 'scales', 'magrittr', 'gridExtra',
		'rmarkdown', 'knitr', 'prettydoc', 'DT', 'car', 'broom', 'nlme', 'lmerTest',
    'readxl', 'openxlsx', 'stringr')

	if(interactive()){
		invisible(sapply(auto_packages, auto_load))
	}

	# rm funtions `R.profile`
		rm(list = ls(all = T))
}
mvazquezs/chmitools documentation built on March 24, 2019, 5:20 p.m.