findDateInterval <- function(dateSamples) {
## Finds the date interval represented in dateSamples
## This is a sloppy function and should be used with caution


## If they are all the first of the month, then use 'month'
    dateSamples <- sort(unique(dateSamples))
    dateDiffs <- as.numeric(abs(diff(dateSamples)))
      ## remove the 0's
      dateDiffs <- dateDiffs[dateDiffs != 0]

    {
      if ( all(1 == lubridate::day(dateSamples)) )
        ret <- "month"
      else if (all((dateDiffs %% 7) == 0)  &&  min(dateDiffs, 1e7) == 7)
        ret <- "week"
      else if (all((dateDiffs %% 1) == 0)  &&  (sum(dateDiffs == 1) > (0.1 * length(dateDiffs))))
        ret <- "day"
      else 
        ret <- NA
    }

  return(ret)
}