### GOAL: Iterate over every set of aggdBy in namesParsed and for each one 
##          create the appropriate graph object (saved to G[[.]] )
##        Addl 1:  Add the TOTAL values for specific fields
##        Addl 2:  Clean the Gender column
##       

## Create namesParsed
keepOnlyThoseWithDates <- FALSE
namesParsed <- createNamesParsed(fbDTnms, keepOnlyThoseWithDates=keepOnlyThoseWithDates)

# -   ## If needed, can use
# -   namesParsed[, list(list(aggdBy)), by=DT.nm]

## Collect all of the unique aggdBy values
aggdByVlues <- attr(namesParsed, "unique.aggdBy")

## Create index list out of all the possible combinations
maxGroupSize <- length( setdiff(aggdByVlues,"") )
categ.cols.using        <- createIndsMatrix(aggdByVlues, maxGroupSize=maxGroupSize)

## Do I want to throw a warning when none-unique rows? 
uniqueCheck <- TRUE

## POSSIBLE TODO:   I might need to create a new table for each combination of "TOTALS"
cls(10)
s.t({
# -------------- YES DATES ------------------ #
  names(categ.cols.using) <- lapply(categ.cols.using, makeAggName, date=TRUE)
                    # ---------- #
  resetCounter("getDTwithTotals")
  ALL.DTs.yes.totals.yes.dates <- lapply(categ.cols.using, getDTwithTotals, useDate=TRUE, removeUnknownGend=TRUE, addGVisID=TRUE, cleanCamp=FALSE, uniqueCheck=uniqueCheck, iter=FALSE)
  ALL.DTs.no.totals.yes.dates   <- lapply(categ.cols.using, getDTwithTotals, useDate=TRUE, removeUnknownGend=TRUE, addGVisID=TRUE, cleanCamp=FALSE, add.totals.for=NULL, uniqueCheck=uniqueCheck)
# -------------- YES DATES ------------------ #
}, "Creating Dates Tables")

s.t({
# -------------- NO DATES ------------------ #
  names(categ.cols.using) <- lapply(categ.cols.using, makeAggName, date=FALSE)
                    # ---------- #
  resetCounter("getDTwithTotals")
  ALL.DTs.yes.totals.no.dates <- lapply(categ.cols.using, getDTwithTotals, useDate=FALSE, removeUnknownGend=TRUE, addGVisID=TRUE, cleanCamp=FALSE, uniqueCheck=uniqueCheck, debug=FALSE, browser=FALSE, iter=FALSE)
  print("   ", quote=FALSE); resetCounter("getDTwithTotals")
  ALL.DTs.no.totals.no.dates   <- lapply(categ.cols.using, getDTwithTotals, useDate=FALSE, removeUnknownGend=TRUE, addGVisID=TRUE, cleanCamp=FALSE, add.totals.for=NULL, uniqueCheck=uniqueCheck, iter=TRUE)
# -------------- NO DATES ------------------ #
}, "Creating No-Dates Tables")



DTNameIs <- function(x, main=FALSE, names=FALSE) {
  if (is.list(x) && !is.twodim(x)) {
      f <- if (!names) unname else identity
      return(f(sapply(x, DTNameIs, main=main)))
    }
  if (main)
    return(attributes(x)$aggInfo$mainDT.nm)
  return(attributes(x)$aggInfo$totsDT.nm)
}

cat("\n",
sideByside(center(DTNameIs(ALL.DTs.no.totals.yes.dates), align="LEFT"), center(DTNameIs(ALL.DTs.yes.totals.yes.dates), align="LEFT")), sep="\n ")


#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #

# I have four ALL.DTs.__  lists: 
#     dates  (Y / N)
#     totals (Y / N)
# They are
#   ALL.DTs.yes.totals.yes.dates
#   ALL.DTs.no.totals.yes.dates
#   ALL.DTs.no.dates.with.totals
#   ALL.DTs.no.dates.no.totals



# :    From here go to one of two places: 
# :    
# :    05 Gvis on Date
# :    05 Gvis on Demog 
# :    
