diff --git a/DESCRIPTION b/DESCRIPTION index cf93a23d..68f00e49 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Description: Create beautiful and customizable tables to summarize several RTF, JPG, or PNG. Tables can easily be embedded in 'Rmarkdown' or 'knitr' dynamic documents. Details can be found in Arel-Bundock (2022) . -Version: 2.1.1 +Version: 2.1.1.1 Authors@R: c(person("Vincent", "Arel-Bundock", email = "vincent.arel-bundock@umontreal.ca", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 6934cce6..17a83c3c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # News +## Development + +* `coef_rename()` gets a `poly=TRUE` argument to rename `poly(x, 2)`-style coefficients. Thanks to @mccarthy-m-g for code contribution #778. + ## 2.1.1 * Documentation improvements diff --git a/R/coef_rename.R b/R/coef_rename.R index b24ff1d3..cf8379a8 100644 --- a/R/coef_rename.R +++ b/R/coef_rename.R @@ -7,6 +7,7 @@ #' @param factor boolean remove the "factor()" label #' @param factor_name boolean remove the "factor()" label and the name of the #' variable +#' @param poly boolean remove the "poly()" label and function arguments #' @param backticks boolean remove backticks #' @param titlecase boolean convert to title case #' @param underscore boolean replace underscores by spaces @@ -24,6 +25,7 @@ coef_rename <- function(x, factor = TRUE, factor_name = TRUE, + poly = TRUE, backticks = TRUE, titlecase = TRUE, underscore = TRUE, @@ -36,6 +38,10 @@ coef_rename <- function(x, out <- gsub("factor\\((.*)\\)", "\\1 ", out) } + if (isTRUE(poly)) { + out <- gsub("poly\\(([^,]*),.*\\)", "\\1^", out) + } + if (isTRUE(underscore)) { out <- gsub("_", " ", out) } diff --git a/man/coef_rename.Rd b/man/coef_rename.Rd index a3d5c0f6..618ebbcb 100644 --- a/man/coef_rename.Rd +++ b/man/coef_rename.Rd @@ -8,6 +8,7 @@ coef_rename( x, factor = TRUE, factor_name = TRUE, + poly = TRUE, backticks = TRUE, titlecase = TRUE, underscore = TRUE, @@ -22,6 +23,8 @@ coef_rename( \item{factor_name}{boolean remove the "factor()" label and the name of the variable} +\item{poly}{boolean remove the "poly()" label and function arguments} + \item{backticks}{boolean remove backticks} \item{titlecase}{boolean convert to title case}