From ccf77c5f1e52f8f70be9e48123325ccdb5d51ee3 Mon Sep 17 00:00:00 2001 From: Tanguy BARTHELEMY Date: Wed, 14 Aug 2024 23:38:05 +0200 Subject: [PATCH] update print method and document --- NAMESPACE | 1 - NEWS.md | 10 +++++++++ R/format_table.R | 2 -- R/revision_analysis.R | 41 +++++++++++++--------------------- R/revisions.R | 2 +- R/vintages.R | 2 +- man/View.rjd3rev_rslts.Rd | 6 ++--- man/print.rjd3rev_revisions.Rd | 2 +- man/print.rjd3rev_rslts.Rd | 12 ++++------ man/print.rjd3rev_vintages.Rd | 2 +- man/summary.rjd3rev_rslts.Rd | 6 ++--- 11 files changed, 40 insertions(+), 46 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 5ff7b67..9f2c9b7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,7 +16,6 @@ S3method(create_vintages,matrix) S3method(create_vintages,mts) S3method(plot,rjd3rev_revisions) S3method(plot,rjd3rev_vintages) -S3method(print,default) S3method(print,rjd3rev_revisions) S3method(print,rjd3rev_rslts) S3method(print,rjd3rev_vintages) diff --git a/NEWS.md b/NEWS.md index 547f524..7d02812 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,8 +8,18 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + * user-defined thresholds for tests assessment * possibility to add plot of revisions in report +* New `View()`, `summary()` and `print()` method to visualize the revision analysis + + +### Changed + +* pivot from {formattable} dependency to {flextable} to build the tables +* `simulate_long()` is now an exported function to construct datasets example + ## [1.3.2] - 2024-07-10 diff --git a/R/format_table.R b/R/format_table.R index 425fa32..0e48565 100644 --- a/R/format_table.R +++ b/R/format_table.R @@ -43,5 +43,3 @@ format_table <- function(x, col = "Tests") { colnames(formatted_table)[1] <- col return(formatted_table) } - - diff --git a/R/revision_analysis.R b/R/revision_analysis.R index cfb342c..4801ae2 100644 --- a/R/revision_analysis.R +++ b/R/revision_analysis.R @@ -700,21 +700,25 @@ regression_diagnostics <- function(reg_output, thr_res_jb, thr_res_bp, thr_res_w # Generic functions ------------------------------------------------------------ -#' Print function for objects of class "rjd3rev_rslts" -#' @export +#' @title Print function for objects of class \code{rjd3rev_rslts} +#' +#' @param x an object of class \code{rjd3rev_rslts} +#' @param \dots further arguments passed to the \code{\link{print}} function. +#' #' @exportS3Method print rjd3rev_rslts +#' @method print rjd3rev_rslts +#' @export #' print.rjd3rev_rslts <- function(x, ...) { - print(list(call = x$call, - descriptive_statistics = x$descriptive.statistics, - parametric_analysis = x$summary, ...)) + print(x$summary) } -#' Summary function for objects of class "rjd3rev_rslts" +#' Summary function for objects of class \code{rjd3rev_rslts} #' -#' @param object an object of class "rjd3rev_rslts" +#' @param object an object of class \code{rjd3rev_rslts} #' @param ... further arguments passed to or from other methods. #' @exportS3Method summary rjd3rev_rslts +#' @method summary rjd3rev_rslts #' @export #' summary.rjd3rev_rslts <- function(object, ...) { @@ -738,18 +742,6 @@ summary.rjd3rev_rslts <- function(object, ...) { print(summary_tests) } -#' print function for objects of class "rjd3rev_rslts" -#' -#' @param x an object of class "rjd3rev_rslts" -#' @param ... further arguments passed to or from other methods. -#' @exportS3Method print rjd3rev_rslts -#' @method print default -#' @export -#' -print.rjd3rev_rslts <- function(x, ...) { - print(x$summary) -} - #' @rdname View #' @export View <- function(x, ...) { @@ -798,10 +790,9 @@ build_table <- function(x, type = c("summary", "stats-desc", "revisions", "tests theme_design() return(stat_desc) } else if (type == "revisions") { - revisions_table <- data.frame( - Time = time(x$revisions), - x$revisions, - check.names = FALSE) |> + revisions_table <- data.frame(Time = time(x$revisions), + x$revisions, + check.names = FALSE) |> flextable::flextable() |> theme_design() return(revisions_table) @@ -812,9 +803,9 @@ build_table <- function(x, type = c("summary", "stats-desc", "revisions", "tests return(invisible(NULL)) } -#' View function for objects of class "rjd3rev_rslts" +#' View function for objects of class \code{rjd3rev_rslts} #' -#' @param x an object of class "rjd3rev_rslts" +#' @param x an object of class \code{rjd3rev_rslts} #' @param type type of view to display #' @param ... further arguments passed to \code{\link{View}}. #' diff --git a/R/revisions.R b/R/revisions.R index a020626..26d05c0 100644 --- a/R/revisions.R +++ b/R/revisions.R @@ -108,7 +108,7 @@ plot.rjd3rev_revisions <- function(x, view = c("vertical", "diagonal"), n_rev = #' @param n_col number of columns to display. Can be either the last n columns #' (verical view), the last n rows (horizontal view) or the first n columns #' (diagonal view). -#' @param \dots further arguments passed to the print() function. +#' @param \dots further arguments passed to the \code{\link{print}} function. #' @exportS3Method print rjd3rev_revisions #' @export #' diff --git a/R/vintages.R b/R/vintages.R index afaebb5..4af7560 100644 --- a/R/vintages.R +++ b/R/vintages.R @@ -493,7 +493,7 @@ create_vintages_from_xlsx <- function(file, #' @param n_col number of columns to display. Can be either the last n columns #' (verical view), the last n rows (horizontal view) or the first n columns #' (diagonal view). This argument is not used for the long view. -#' @param ... further arguments passed to the print() function. +#' @param ... further arguments passed to the \code{\link{print}} function. #' #' @exportS3Method print rjd3rev_vintages #' @method print rjd3rev_vintages diff --git a/man/View.rjd3rev_rslts.Rd b/man/View.rjd3rev_rslts.Rd index 3c0d2a4..a7e622b 100644 --- a/man/View.rjd3rev_rslts.Rd +++ b/man/View.rjd3rev_rslts.Rd @@ -2,17 +2,17 @@ % Please edit documentation in R/revision_analysis.R \name{View.rjd3rev_rslts} \alias{View.rjd3rev_rslts} -\title{View function for objects of class "rjd3rev_rslts"} +\title{View function for objects of class \code{rjd3rev_rslts}} \usage{ \method{View}{rjd3rev_rslts}(x, type = c("all", "summary", "stats-desc", "revisions", "tests"), ...) } \arguments{ -\item{x}{an object of class "rjd3rev_rslts"} +\item{x}{an object of class \code{rjd3rev_rslts}} \item{type}{type of view to display} \item{...}{further arguments passed to \code{\link{View}}.} } \description{ -View function for objects of class "rjd3rev_rslts" +View function for objects of class \code{rjd3rev_rslts} } diff --git a/man/print.rjd3rev_revisions.Rd b/man/print.rjd3rev_revisions.Rd index 16bf344..3303273 100644 --- a/man/print.rjd3rev_revisions.Rd +++ b/man/print.rjd3rev_revisions.Rd @@ -16,7 +16,7 @@ corresponds to the number of columns.} (verical view), the last n rows (horizontal view) or the first n columns (diagonal view).} -\item{\dots}{further arguments passed to the print() function.} +\item{\dots}{further arguments passed to the \code{\link{print}} function.} } \description{ Print function for objects of class \code{"rjd3rev_revisions"} diff --git a/man/print.rjd3rev_rslts.Rd b/man/print.rjd3rev_rslts.Rd index 7cacd1c..a69e433 100644 --- a/man/print.rjd3rev_rslts.Rd +++ b/man/print.rjd3rev_rslts.Rd @@ -2,19 +2,15 @@ % Please edit documentation in R/revision_analysis.R \name{print.rjd3rev_rslts} \alias{print.rjd3rev_rslts} -\title{Print function for objects of class "rjd3rev_rslts"} +\title{Print function for objects of class \code{rjd3rev_rslts}} \usage{ \method{print}{rjd3rev_rslts}(x, ...) - -\method{print}{default}(x, ...) } \arguments{ -\item{x}{an object of class "rjd3rev_rslts"} +\item{x}{an object of class \code{rjd3rev_rslts}} -\item{...}{further arguments passed to or from other methods.} +\item{\dots}{further arguments passed to the \code{\link{print}} function.} } \description{ -Print function for objects of class "rjd3rev_rslts" - -print function for objects of class "rjd3rev_rslts" +Print function for objects of class \code{rjd3rev_rslts} } diff --git a/man/print.rjd3rev_vintages.Rd b/man/print.rjd3rev_vintages.Rd index b1503f8..4be2b9c 100644 --- a/man/print.rjd3rev_vintages.Rd +++ b/man/print.rjd3rev_vintages.Rd @@ -16,7 +16,7 @@ corresponds to the number of columns.} (verical view), the last n rows (horizontal view) or the first n columns (diagonal view). This argument is not used for the long view.} -\item{...}{further arguments passed to the print() function.} +\item{...}{further arguments passed to the \code{\link{print}} function.} } \description{ Print function for objects of class \code{"rjd3rev_vintages"} diff --git a/man/summary.rjd3rev_rslts.Rd b/man/summary.rjd3rev_rslts.Rd index d6048e0..c5993ff 100644 --- a/man/summary.rjd3rev_rslts.Rd +++ b/man/summary.rjd3rev_rslts.Rd @@ -2,15 +2,15 @@ % Please edit documentation in R/revision_analysis.R \name{summary.rjd3rev_rslts} \alias{summary.rjd3rev_rslts} -\title{Summary function for objects of class "rjd3rev_rslts"} +\title{Summary function for objects of class \code{rjd3rev_rslts}} \usage{ \method{summary}{rjd3rev_rslts}(object, ...) } \arguments{ -\item{object}{an object of class "rjd3rev_rslts"} +\item{object}{an object of class \code{rjd3rev_rslts}} \item{...}{further arguments passed to or from other methods.} } \description{ -Summary function for objects of class "rjd3rev_rslts" +Summary function for objects of class \code{rjd3rev_rslts} }