Skip to content

Commit 105dba6

Browse files
committed
add examples
1 parent 45854c4 commit 105dba6

10 files changed

Lines changed: 152 additions & 1 deletion

R/revisions.R

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,19 @@ get_first_efficient_release <- function(
566566
#' @return The function returns the input \code{x} invisibly.
567567
#' @method print lst_efficient
568568
#' @family revision analysis
569+
#' @examples
570+
#' df <- get_nth_release(
571+
#' tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")),
572+
#' n = 0:3
573+
#' )
574+
#'
575+
#' final_release <- get_nth_release(
576+
#' tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")),
577+
#' n = 10
578+
#' )
579+
#'
580+
#' result <- get_first_efficient_release(df, final_release, significance = 0.05)
581+
#' print(result)
569582
#' @export
570583
print.lst_efficient <- function(x, ...) {
571584
summary.lst_efficient(x, ...)
@@ -1132,6 +1145,36 @@ get_revision_analysis <- function(
11321145
#' @return The function returns the input \code{x} invisibly.
11331146
#' @method print revision_summary
11341147
#' @family revision analysis
1148+
#' @examples
1149+
#' df <- dplyr::select(
1150+
#' get_nth_release(
1151+
#' na.omit(
1152+
#' tsbox::ts_pc(
1153+
#' dplyr::filter(reviser::gdp, id == "US")
1154+
#' )
1155+
#' ),
1156+
#' n = 0:3
1157+
#' ),
1158+
#' -"pub_date"
1159+
#' )
1160+
#'
1161+
#' final_release <- dplyr::select(
1162+
#' get_nth_release(
1163+
#' na.omit(
1164+
#' tsbox::ts_pc(
1165+
#' dplyr::filter(reviser::gdp, id == "US")
1166+
#' )
1167+
#' ),
1168+
#' n = "latest"
1169+
#' ),
1170+
#' -"pub_date"
1171+
#' )
1172+
#'
1173+
#' results <- get_revision_analysis(df, final_release, degree = 1)
1174+
#' print(results)
1175+
#'
1176+
#' # Print without interpretation
1177+
#' print(results, interpretation = FALSE)
11351178
#' @export
11361179
print.revision_summary <- function(x, interpretation = TRUE, digits = 3, ...) {
11371180
cat("\n=== Revision Analysis Summary ===\n\n")

R/utils.R

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ make_explicit_missing <- function(
706706
#' @return A named character vector where names are labels and values are
707707
#' the corresponding information. The vector is used by pillar to format
708708
#' the tibble header.
709+
#' @examples
710+
#' df <- dplyr::filter(reviser::gdp, id == "US")
711+
#' wide_data <- vintages_wide(df)
712+
#' pillar::tbl_sum(wide_data$US)
709713
#' @family helpers
710714
#' @export
711715
tbl_sum.tbl_pubdate <- function(x, ...) {
@@ -744,10 +748,13 @@ tbl_sum.tbl_pubdate <- function(x, ...) {
744748
#'
745749
#' @return The input \code{x} is returned invisibly.
746750
#' @method print tbl_pubdate
751+
#' @examples
752+
#' df <- dplyr::filter(reviser::gdp, id == "US")
753+
#' wide_data <- vintages_wide(df)
754+
#' print(wide_data$US)
747755
#' @family helpers
748756
#' @export
749757
print.tbl_pubdate <- function(x, ...) {
750-
# Delegate to tibble's print method, which will call tbl_sum.tbl_pubdate
751758
NextMethod("print")
752759
invisible(x)
753760
}
@@ -761,6 +768,10 @@ print.tbl_pubdate <- function(x, ...) {
761768
#'
762769
#' @return A named character vector where names are labels and values are
763770
#' the corresponding information.
771+
#' @examples
772+
#' df <- dplyr::filter(reviser::gdp, id == "US")
773+
#' release_data <- get_nth_release(df, n = 0:3)
774+
#' pillar::tbl_sum(release_data)
764775
#' @family helpers
765776
#' @export
766777
tbl_sum.tbl_release <- function(x, ...) {
@@ -796,6 +807,10 @@ tbl_sum.tbl_release <- function(x, ...) {
796807
#'
797808
#' @return The input \code{x} is returned invisibly.
798809
#' @method print tbl_release
810+
#' @examples
811+
#' df <- dplyr::filter(reviser::gdp, id == "US")
812+
#' release_data <- get_nth_release(df, n = 0:3)
813+
#' print(release_data)
799814
#' @family helpers
800815
#' @export
801816
print.tbl_release <- function(x, ...) {
@@ -810,6 +825,10 @@ print.tbl_release <- function(x, ...) {
810825
#'
811826
#' @return The function returns a summary tibble invisibly.
812827
#' @method summary tbl_pubdate
828+
#' @examples
829+
#' df <- dplyr::filter(reviser::gdp, id == "US")
830+
#' wide_data <- vintages_wide(df)
831+
#' summary(wide_data$US)
813832
#' @family helpers
814833
#' @export
815834
summary.tbl_pubdate <- function(object, ...) {
@@ -863,6 +882,15 @@ summary.tbl_pubdate <- function(object, ...) {
863882
#'
864883
#' @return The function returns a summary tibble invisibly.
865884
#' @method summary tbl_release
885+
#' @examples
886+
#' df <- dplyr::filter(reviser::gdp, id == "US")
887+
#' # Long format
888+
#' release_data <- get_nth_release(df, n = 0:3)
889+
#' summary(release_data)
890+
#'
891+
#' # Wide format
892+
#' wide_release <- vintages_wide(release_data, names_from = "release")
893+
#' summary(wide_release$US)
866894
#' @family helpers
867895
#' @export
868896
summary.tbl_release <- function(object, ...) {

man/print.lst_efficient.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.revision_summary.Rd

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.tbl_pubdate.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.tbl_release.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/summary.tbl_pubdate.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/summary.tbl_release.Rd

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tbl_sum.tbl_pubdate.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tbl_sum.tbl_release.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)