Debian Codegraph @

R/kendall.R

raw
1 #' @templateVar class Kendall
2 #' @template title_desc_tidy
3 #'
4 #' @param x A `Kendall` object returned from a call to [Kendall::Kendall()],
5 #' [Kendall::MannKendall()], or [Kendall::SeasonalMannKendall()].
6 #' @template param_unused_dots
7 #'
8 #' @evalRd return_tidy(
9 #' "p.value",
10 #' "kendall_score",
11 #' "var_kendall_score",
12 #' statistic = "Kendall's tau statistic",
13 #' denominator = "The denominator, which is tau=kendall_score/denominator."
14 #' )
15 #'
16 #' @examplesIf rlang::is_installed("Kendall")
17 #'
18 #' # load libraries for models and data
19 #' library(Kendall)
20 #'
21 #' A <- c(2.5, 2.5, 2.5, 2.5, 5, 6.5, 6.5, 10, 10, 10, 10, 10, 14, 14, 14, 16, 17)
22 #' B <- c(1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2)
23 #'
24 #' # fit models and summarize results
25 #' f_res <- Kendall(A, B)
26 #' tidy(f_res)
27 #'
28 #' s_res <- MannKendall(B)
29 #' tidy(s_res)
30 #'
31 #' t_res <- SeasonalMannKendall(ts(A))
32 #' tidy(t_res)
33 #'
34 #' @export
35 #' @seealso [tidy()], [Kendall::Kendall()], [Kendall::MannKendall()],
36 #' [Kendall::SeasonalMannKendall()]
37 #' @aliases Kendall_tidiers kendall_tidiers
38 #'
39 tidy.Kendall <- function(x, ...) {
40 col_names <- c(
41 "statistic",
42 "p.value",
43 "kendall_score",
44 "denominator",
45 "var_kendall_score"
46 )
47 ret <- as_tibble(unclass(x))
48 set_names(ret, col_names)
49 }