  # ----------------------------------------------------------------------------------------------------------------------------  #
  #  --------------------------------------------------------------------------------------------------------------------------   #
  #                                                                                                                               #
  #           File Name              :  ggSpacer.r                                                                                #
  #           Last Updated Funclist  :  19 Feb 2015,  1:05 PM (Thursday)                                                          #
  #                                                                                                                               #
  #           Author Name            :  Rick Saporta                                                                              #
  #           Author Email           :  RickSaporta@gmail.com                                                                     #
  #           Author URL             :  www.github.com/rsaporta                                                                   #
  #                                                                                                                               #
  #           Packages Called        :  NA                                                                                        #
  #           Packages Used via NS   :  NA                                                                                        #
  #                                                                                                                               #
  #  --------------------------------------------------------------------------------------------------------------------------   #
  #                                                                                                                               #
  #   ggSpacer           ( DT                                                                                                     #
  #                        , location=c("topleft", "topright", "bottomleft", "bottomright", "tl", "tr", "bl", "br"), xvalue=NULL  #
  #                        , yvalue=NULL, xcol=names(DT)[[1]], ycol=names(DT)[[2]], xscale=1, yscale=1, byCols=NULL               #
  #                        , na.rm=TRUE, x.na.rm=na.rm, y.na.rm=na.rm )                                                           #
  #   xFunc              ( ... )                                                                                                  #
  #   yFunc              ( ... )                                                                                                  #
  #                                                                                                                               #
  #                                                                                                                               #
  #                                                       <END FUNCS>                                                             #
  #  --------------------------------------------------------------------------------------------------------------------------   #
  # ----------------------------------------------------------------------------------------------------------------------------  #

ggSpacer <- function(DT
  , location=c("topleft", "topright", "bottomleft", "bottomright", "tl", "tr", "bl", "br")
  , xvalue=NULL, yvalue=NULL
  , xcol=names(DT)[[1]], ycol=names(DT)[[2]]
  , xscale=1.0, yscale=1.0
  , byCols=NULL, na.rm=TRUE, x.na.rm=na.rm, y.na.rm=na.rm) {
  ##  If value argument is given, that will be the value used, 
  ##  other wise, using the 'Func(col) * scale'
  ##  use EITHER the 'value' argument or the 'col' argument, but not both. 
  ##
  ## TODO:  Add an option to reverse x and reverse y

  ## Confirm valid input
  if (!(missing(xcol) || is.null(xcol)) && !is.null(xvalue))
    stop ("dont use xcol and xvalue -- pick one")
  if (!(missing(ycol) || is.null(ycol)) && !is.null(yvalue))
    stop ("dont use ycol and yvalue -- pick one")


  ## Cleanup location and extract v/h
  location <- match.arg(location, several.ok=FALSE)
  for (word in c("top", "bottom", "left", "right"))
    location <- gsub(word, substr(word, 1, 1), location)
  v <- substr(location, 1, 1)
  h <- substr(location, 2, 2)

  ## Grab functions based on location value
  xFunc <- if(v=="t") max else min
  yFunc <- if(h=="r") max else min

  ## 'trick' for value is to have the function simply return that value
  if (!is.null(xvalue))
    xFunc <- function(...) return(xvalue)
  if (!is.null(yvalue))
    yFunc <- function(...) return(yvalue)

  data <- DT[, list(x=xFunc(get(xcol), na.rm=x.na.rm), y=yFunc(get(ycol), na.rm=y.na.rm)), by=byCols]
  if (!nrow(data)) {
    warning ("data has no rows, returning NULL")
    return(NULL)
  }

  if (is.numeric(data$x) && xscale != 1 && is.null(xvalue))
    data[, x := x * xscale]
  if (is.numeric(data$y) && yscale != 1 && is.null(yvalue))
    data[, y := y * yscale]

  geom_point(data=data, aes(x=x, y=y), size=0, color="BLUE", fill="RED", guides=FALSE)
}
