## 00b Initialize Project.r


#------------------------------------------------------------------#
#       PACKAGES                                                   #
#------------------------------------------------------------------#
  library("data.table")
  library("ggplot2")
#------------------------------------------------------------------#


#------------------------------------------------------------------#
#       SOURCE UTILS FUNCTIONS                                     #
#------------------------------------------------------------------#
  ## This entire section is a lot of error checking around finding the .us() function

  if (!exists(".us") && !exists("utilSource")) {
    if (file.exists("~/git/misc/rscripts/utilsRS.r"))
      source("~/git/misc/rscripts/utilsRS.r")
    else 
      stop("Cannot find main 'utilSource()' function nor the 'utilsRS.r' file")
  }

  ## Run utilSource twice, on purpose
  if (exists(".us")) {
      .us(); .g(); .us(); .us()
  } else if (exists("utilSource")) {
    utilSource(); .g(); utilSource(); utilSource()
  } else
    stop("Cannot find main 'utilSource()' function")
#------------------------------------------------------------------#


#------------------------------------------------------------------#
#       WORKSPACE SETUP                                            #
#------------------------------------------------------------------#
  projName <- "PeerGroups"

  setScience(projName=projName, loadImage=FALSE, subl=FALSE)
  sourceSupportFns(fail=FALSE, verbose=FALSE)

  # if flagged to TRUE, any loaded data will be deleted after no longer needed
  cleanUpAfterOurselves <- TRUE

  # which platform are we working on
  .Pfm <- Sys.info()[['sysname']]
#------------------------------------------------------------------#




