-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c44a832
commit 8bc5f91
Showing
6 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#' Time Series Islands | ||
#' | ||
#' Find 'island rows' in a dataset with ordered rows. Islands have a | ||
#' series variable that is not `NA` surrounded by `NA` values in that | ||
#' same variable. | ||
#' | ||
#' @param data A dataset (must be ordered if `time_variable` is `NULL`). | ||
#' @param series_variable Name of a series variable. | ||
#' @param time_variable Optional variable to use for ordering the dataset | ||
#' before islands are located. | ||
#' | ||
#' @importFrom dplyr arrange mutate | ||
#' @export | ||
time_series_islands = function(data, series_variable, time_variable = NULL) { | ||
if (!is.null(time_variable)) data = arrange(data, get(time_variable)) | ||
filter(data, | ||
is.na(lag(get(series_variable))) & is.na(lead(get(series_variable))) | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.