## noheader


        ~~~   BEFORE TRASHING:    See notes, and see if they are of any use. 









        


LOOK AT  

     setScience()







TODO: 
First clean up file structure, then set this up 


WorkSpaceSetup <- function(projDir, Pfm=Sys.info()[['sysname']]) { 
# set up personal workspace based on which system I am working from 
#
# Explanation: 
# I normally have three dir variables: 
#  dataDir:  Load from and save to, backups of images and large objects
#   srcDir:  Code for the current project
#   outDir:  Save output, such as pdfs, csvs, or anything that might need to be sent/shared

# for NBS projects, I also have a baseDir and a projDir, where
#  baseDir  is simply where all of my projects reside (and is aa function of which system I am working form)
#  projDir  is the folder in baseDir specific to the current project

# Complication:   Many projects share the same data, and hence to avoid 
#                 wasting drive space they should share the same data folder
  ~/git/nbs/src
  ~/NBS-R/Ricks

}


...  BELOW ARE SOME OF THE OTHER FUNCTIONS

# LoadFromNBSData()
function(objToLoad, pos=1, Pfm=Sys.info()[['sysname']], force=FALSE) { 
# Wrapper function with the NBS data dir pre populated

   # set Dir to load backups from based on which system working from  
    BackUpFrom <- "~/NBS-R/Ricks/data/"
    BackUpFrom <- ifelse(Pfm=="Linux", BackUpFrom, "/Users/ricardosaporta/gitData/nbs/data")
    return(checkAndLoad(objToLoad, BackUpFrom, pos=pos+1, force=force))
}

# dosDir()
function(wrkDir=getwd(), gitData=FALSE, mkdir=FALSE, pos=1, silent=FALSE) {
  # makes data, out, src directory inside the directory wrkDir
  #   and creates variables with full path to these directories
  #   in the parent environment  (the environment that called this func) 
  # 
  
  grp <- list("data", "out", "src")
  
  # create vars (+'Dir') and vals (paths)
  vars <- paste0(grp, "Dir")
  vals <- mapply(as.path, wrkDir, grp, MoreArgs=list(expand=FALSE), USE.NAMES=FALSE)
  
  # if flagged, data dir will be in different directory
  if (gitData)
    #    vals[[which(grp=="data")]] <- sub("/git/", "/gitData/", eval(vals[[1]], envir=parent.frame()))
    vals[[which(grp=="data")]] <- sub("/git/", "/gitData/", vals[[which(grp=="data")]])
  
  
  # if flagged, create directories if they do not exist
  if (mkdir) {
    if(!silent) cat("Creating Directories (if not exist)... \n")
    sapply(path.expand(vals), dir.create, showWarnings=FALSE, recursive=TRUE)
    if(!silent) cat("\n    ----     \n")
  }
  
  if(!silent) cat("\n\tVariables have been created: \n")
  # assign vals to appropriate var names in the calling environment                  
  mapply(assign, vars, vals, MoreArgs=c(pos=parent.frame(pos)))
}
