-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to build cumulative ranges #61
Comments
It may be useful to make the overlapping range by sliding window configurable. For example, when we have a sliding window size of one year, it could be interesting to have an overlapping range of 3 month or 25%. It is similar to cumulative ranges but without very old edges and nodes. |
An idea to implement that would be to supply a function to construct overlapping ranges (similar to This way, we would not need to extend the existing functions by even more stuff... |
I am currently constructing a function to construct overlapping ranges. I would like your opinion on the signature and the respective documentation. What are your thoughts on this? #' Construct ranges based on the given start time, end time, time period, and overlap.
#'
#' With this function, it is possible to construct ranges like this:
#' > ++++
#' > .++++
#' > ..++++
#'
#' With \code{overlap} being the half of \code{time.period}, we basically obtain half-
#' overlapping ranges as in the function \code{construct.ranges} when \code{sliding.window}
#' is set to \code{TRUE}.
#'
#' Note: You may want to use the function \code{ProjectData$get.data.timestamps} with this
#' function here.
#'
#' @param start The start time as string or POSIXct object
#' @param end The start time as string or POSIXct object
#' @param time.period The time period describing the length of the ranges, a character
#' string, e.g., "3 mins" or "15 days"
#' @param overlap The time period describing the length of the overlap, a character string,
#' e.g., "3 mins" or "15 days". Needs to be more than 0 seconds and
#' smaller than the given \code{time.period}.
#' @param raw whether to return pairs of POSIXct objects or strings rather than
#' formatted strings [default: FALSE]
#'
#' @return the constructed ranges, either formatted or raw
construct.overlapping.ranges = function(start, end, time.period, overlap, raw = FALSE) { |
@clhunsen Could you add an example here, please? It would be helpful to see the outcome of the function based on an example input. In addition, according to Barbara's example, it may be useful to not only allow specifying the |
At the time of writing the previous post, I had not had implemented the function yet... 😉 So, here, the example now (analogous output as for the function rev1 = ("2015-01-01 00:00:00")
rev2 = ("2015-01-01 06:00:00")
construct.overlapping.ranges(rev1, rev2, time.period = "2 hours", overlap = "30 minutes")
# [1] "2015-01-01 00:00:00-2015-01-01 02:00:00"
# [2] "2015-01-01 01:30:00-2015-01-01 03:30:00"
# [3] "2015-01-01 03:00:00-2015-01-01 05:00:00"
# [4] "2015-01-01 04:30:00-2015-01-01 06:00:00"
construct.overlapping.ranges(rev1, rev2, time.period = "2 hours", overlap = " 0 minutes", raw = TRUE)
# $`2015-01-01 00:00:00-2015-01-01 02:00:00`
# [1] "2015-01-01 00:00:00 UTC" "2015-01-01 02:00:00 UTC"
#
# $`2015-01-01 02:00:00-2015-01-01 04:00:00`
# [1] "2015-01-01 02:00:00 UTC" "2015-01-01 04:00:00 UTC"
#
# $`2015-01-01 04:00:00-2015-01-01 06:00:00`
# [1] "2015-01-01 04:00:00 UTC" "2015-01-01 06:00:00 UTC"
What about a parameter |
As we can construct cumulative ranges and also overlapping ranges now, I will close this issue. |
It may be useful to be able to construct cumulative ranges when splitting data or networks.
For instance, the first range should contain the first three months, the second range the first six month, the third range the first nine month, and so on...
To achieve this, we should split the data into equal ranges (three months in the example above) and then combine subsequent ranges to get the cumulative ranges.
Therefore, we need some additional functions for combining data or networks, which we can collect in a new file called
util-combine.R
, for example.A function for combining networks does already exist in another repository, which can be moved from the other repository into this one (see #11).
The text was updated successfully, but these errors were encountered: