X-Git-Url: https://git.auder.net/doc/html/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=pkg%2FR%2Futils.R;h=3649f5865a72fbeeb182cd6ef677fcb963b361e9;hb=6774e53de7b8bdac191d6203a380ad46c3b4d9ba;hp=b3e66e18d109f9bd56ece2618f204422f2bd63a0;hpb=ee8b1b4e3c13f8dcf13a2c8da6a3bef1520c8252;p=talweg.git
diff --git a/pkg/R/utils.R b/pkg/R/utils.R
index b3e66e1..3649f58 100644
--- a/pkg/R/utils.R
+++ b/pkg/R/utils.R
@@ -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)