-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added
gss()
function from gsdd
package to calculate growing sea…
…sons.
- Loading branch information
1 parent
fa00525
commit f8c0b9c
Showing
10 changed files
with
154 additions
and
6 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
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,29 @@ | ||
#' Calculate Growing Seasons (GSS) | ||
#' | ||
#' A wrapper on [gsdd::gss()] to by default | ||
#' get all Growing Seasons ignoring truncation. | ||
#' For more information see [gsdd::gss()]. | ||
#' | ||
#' @inheritParams gsdd::gdd | ||
#' @seealso [gsdd::gss()], [gsdd()] and [gss()]. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' gss(gsdd::temperature_data) | ||
gss <- function( | ||
x, | ||
min_length = 120, | ||
ignore_truncation = TRUE, | ||
pick = "all", | ||
msgs = TRUE | ||
) { | ||
chk_whole_number(min_length) | ||
chk_range(min_length, c(14, 274)) | ||
|
||
gsdd::gss( | ||
x, | ||
min_length = min_length, | ||
ignore_truncation = ignore_truncation, | ||
pick = pick, | ||
msgs = msgs) | ||
} |
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.
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,44 @@ | ||
# gss works | ||
|
||
Code | ||
gss | ||
Output | ||
# A tibble: 1 x 5 | ||
# Groups: year [1] | ||
year start_dayte end_dayte gsdd truncation | ||
<int> <date> <date> <dbl> <chr> | ||
1 2019 1971-03-20 1971-11-07 3899. none | ||
|
||
# gss works t2 | ||
|
||
Code | ||
gss | ||
Output | ||
# A tibble: 2 x 5 | ||
# Groups: year [1] | ||
year start_dayte end_dayte gsdd truncation | ||
<int> <date> <date> <dbl> <chr> | ||
1 2019 1971-04-08 1971-06-04 500 none | ||
2 2019 1971-07-15 1971-09-03 800 none | ||
|
||
# gss truncation off | ||
|
||
Code | ||
gss | ||
Output | ||
# A tibble: 0 x 5 | ||
# i 5 variables: year <int>, start_dayte <date>, end_dayte <date>, gsdd <dbl>, | ||
# truncation <chr> | ||
|
||
# gss truncation on | ||
|
||
Code | ||
gss | ||
Output | ||
# A tibble: 2 x 5 | ||
# Groups: year [1] | ||
year start_dayte end_dayte gsdd truncation | ||
<int> <date> <date> <dbl> <chr> | ||
1 2019 1971-04-08 1971-06-04 500 none | ||
2 2019 1971-07-15 1971-11-30 1255 end | ||
|
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,35 @@ | ||
test_that("gss works", { | ||
gss <- gss(gsdd::temperature_data) | ||
expect_snapshot({ | ||
gss | ||
}) | ||
}) | ||
|
||
test_that("gss works t2", { | ||
data <- gsdd::temperature_data | ||
data$temperature <- data$temperature2 | ||
gss <- gss(data) | ||
expect_snapshot({ | ||
gss | ||
}) | ||
}) | ||
|
||
test_that("gss truncation off", { | ||
data <- gsdd::temperature_data | ||
data$temperature <- data$temperature2 | ||
data$temperature[data$date >= as.Date("2019-08-28")] <- 5 | ||
gss <- gss(data, ignore_truncation = FALSE, msgs = FALSE) | ||
expect_snapshot({ | ||
gss | ||
}) | ||
}) | ||
|
||
test_that("gss truncation on", { | ||
data <- gsdd::temperature_data | ||
data$temperature <- data$temperature2 | ||
data$temperature[data$date >= as.Date("2019-08-28")] <- 5 | ||
gss <- gss(data) | ||
expect_snapshot({ | ||
gss | ||
}) | ||
}) |