No longer direct predict for Neighbors2: recollement comme Neighbors (better)
[talweg.git] / pkg / R / utils.R
index b3e66e1..3649f58 100644 (file)
@@ -59,9 +59,10 @@ integerIndexToDate = function(index, data)
 #' @param data Reference dataset, object output of \code{getData}
 #' @param limit Maximum number of indices to return
 #' @param same_season Should the indices correspond to day in same season?
+#' @param days_in Optional set to intersect with results (NULL to discard)
 #'
 #' @export
-getSimilarDaysIndices = function(index, data, limit, same_season)
+getSimilarDaysIndices = function(index, data, limit, same_season, days_in=NULL)
 {
        index = dateIndexToInteger(index, data)
 
@@ -74,7 +75,7 @@ getSimilarDaysIndices = function(index, data, limit, same_season)
        while (i >= 1 && length(days) < limit)
        {
                dt = as.POSIXlt(data$getTime(i)[1])
-               if (.isSameDay(dt$wday, day_ref))
+               if ((is.null(days_in) || i %in% days_in) && .isSameDay(dt$wday, day_ref))
                {
                        if (!same_season || .isSameSeason(dt$mon+1, month_ref))
                                days = c(days, i)