From db122851844be4d039e535fc799c96dd2f2c7c8d Mon Sep 17 00:00:00 2001 From: Duncan Murdoch Date: Thu, 22 Aug 2024 11:21:37 -0400 Subject: [PATCH] Don't use argument abbreviations. --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ R/tabular.R | 4 ++-- README.Rmd | 2 +- README.md | 2 +- man/Percent.Rd | 6 +++--- man/html.tabular.Rd | 2 +- man/matrix_form.tabular.Rd | 4 ++-- man/tabular.Rd | 4 ++-- vignettes/HTML.Rmd | 2 +- vignettes/knitrTables.Rmd | 6 +++--- vignettes/tables.Rnw | 4 ++-- vignettes/tables.Rout.save | 8 ++++---- 13 files changed, 29 insertions(+), 23 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 00949c4..4c0e9be 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tables Title: Formula-Driven Table Generation -Version: 0.9.28 +Version: 0.9.29 Author: Duncan Murdoch Description: Computes and displays complex tables of summary statistics. Output may be in LaTeX, HTML, plain text, or an R diff --git a/NEWS.md b/NEWS.md index 3e59cac..e57f64a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# tables 0.9.29 + +- In a few places `len` was used instead of `length.out` in calls to +`rep()`, leading to warnings. Similarly, `rep` was used instead of +`replace` in `sample()` (issue #28). + # tables 0.9.28 - A factor level of `""` caused an error when displayed. It will diff --git a/R/tabular.R b/R/tabular.R index e697515..6e761a1 100644 --- a/R/tabular.R +++ b/R/tabular.R @@ -706,14 +706,14 @@ tabular.formula <- function(table, data=NULL, n, suppressLabels=0, ...) { } justify <- function(x, justification="c", width=max(nchar(x))) { - justification <- rep(justification, len=length(x)) + justification <- rep(justification, length.out = length(x)) change <- justification %in% c("c", "l", "r") if (!any(change)) return(x) y <- x[change] justification <- justification[change] y <- sub("^ *", "", y) y <- sub(" *$", "", y) - width <- rep(width, len=length(x)) + width <- rep(width, length.out = length(x)) width <- width[change] lens <- nchar(y) ind <- justification == "c" diff --git a/README.Rmd b/README.Rmd index 1245824..4d32d07 100644 --- a/README.Rmd +++ b/README.Rmd @@ -55,7 +55,7 @@ set.seed(123) table_options(htmloptions(head=FALSE)) X <- rnorm(125, sd=100) -Group <- factor(sample(letters[1:5], 125, rep=TRUE)) +Group <- factor(sample(letters[1:5], 125, replace = TRUE)) tab <- tabular( Group ~ (N=1) + Format(digits=2)*X* diff --git a/README.md b/README.md index 49f4861..82057e7 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ set.seed(123) table_options(htmloptions(head=FALSE)) X <- rnorm(125, sd=100) -Group <- factor(sample(letters[1:5], 125, rep=TRUE)) +Group <- factor(sample(letters[1:5], 125, replace = TRUE)) tab <- tabular( Group ~ (N=1) + Format(digits=2)*X* diff --git a/man/Percent.Rd b/man/Percent.Rd index 2689737..0313f30 100644 --- a/man/Percent.Rd +++ b/man/Percent.Rd @@ -72,9 +72,9 @@ in the \code{denom} argument to \code{Percent}. \seealso{\code{\link{Arguments}} for a different way to specify a multiple argument analysis function.} \examples{ -x <- factor(sample(LETTERS[1:2], 1000, rep=TRUE)) -y <- factor(sample(letters[3:4], 1000, rep=TRUE)) -z <- factor(sample(LETTERS[5:6], 1000, rep=TRUE)) +x <- factor(sample(LETTERS[1:2], 1000, replace = TRUE)) +y <- factor(sample(letters[3:4], 1000, replace = TRUE)) +z <- factor(sample(LETTERS[5:6], 1000, replace = TRUE)) # These both do the same thing: tabular( (x + 1)*(y + 1) ~ (z + 1)*(1+(RowPct=Percent("row")))) diff --git a/man/html.tabular.Rd b/man/html.tabular.Rd index daf80ae..7a84cb7 100644 --- a/man/html.tabular.Rd +++ b/man/html.tabular.Rd @@ -76,7 +76,7 @@ invisibly. \examples{ \donttest{ X <- rnorm(125, sd=100) -Group <- factor(sample(letters[1:5], 125, rep=TRUE)) +Group <- factor(sample(letters[1:5], 125, replace = TRUE)) tab <- tabular( Group ~ (N=1)+Format(digits=2)*X*((Mean=mean) + Heading("Std Dev")*sd) ) diff --git a/man/matrix_form.tabular.Rd b/man/matrix_form.tabular.Rd index b491c2f..91a85bf 100644 --- a/man/matrix_form.tabular.Rd +++ b/man/matrix_form.tabular.Rd @@ -26,8 +26,8 @@ Duncan Murdoch with help from Gabe Becker. } \examples{ if (requireNamespace("formatters")) { - Sex <- factor(sample(c("Male", "Female"), 100, rep=TRUE)) - Status <- factor(sample(c("low", "medium", "high"), 100, rep=TRUE)) + Sex <- factor(sample(c("Male", "Female"), 100, replace = TRUE)) + Status <- factor(sample(c("low", "medium", "high"), 100, replace = TRUE)) z <- rnorm(100) + 5 fmt <- function(x) { s <- format(x, digits=2) diff --git a/man/tabular.Rd b/man/tabular.Rd index c53e986..0e42959 100644 --- a/man/tabular.Rd +++ b/man/tabular.Rd @@ -226,8 +226,8 @@ tabular( (Species + 1) ~ (n=1) + Format(digits=2)* (Sepal.Length + Sepal.Width)*(mean + sd), data=iris ) # This example shows some of the less common options -Sex <- factor(sample(c("Male", "Female"), 100, rep=TRUE)) -Status <- factor(sample(c("low", "medium", "high"), 100, rep=TRUE)) +Sex <- factor(sample(c("Male", "Female"), 100, replace = TRUE)) +Status <- factor(sample(c("low", "medium", "high"), 100, replace = TRUE)) z <- rnorm(100)+5 fmt <- function(x) { s <- format(x, digits=2) diff --git a/vignettes/HTML.Rmd b/vignettes/HTML.Rmd index e8e3ee2..19c2229 100644 --- a/vignettes/HTML.Rmd +++ b/vignettes/HTML.Rmd @@ -31,7 +31,7 @@ library(tables) The table is now constructed in the usual way. ```{r} X <- rnorm(125, sd=100) -Group <- factor(sample(letters[1:5], 125, rep=TRUE)) +Group <- factor(sample(letters[1:5], 125, replace = TRUE)) tab <- tabular( Group ~ (N=1)+Format(digits=2)*X*((Mean=mean) + Heading("Std Dev")*sd) ) ``` In an R Markdown document, you don't want each table diff --git a/vignettes/knitrTables.Rmd b/vignettes/knitrTables.Rmd index 36249fc..f74d22e 100644 --- a/vignettes/knitrTables.Rmd +++ b/vignettes/knitrTables.Rmd @@ -144,7 +144,7 @@ For the examples below we use the following definitions: set.seed(100) X <- rnorm(10) X -A <- sample(letters[1:2], 10, rep=TRUE) +A <- sample(letters[1:2], 10, replace = TRUE) A F <- factor(A) F @@ -1207,8 +1207,8 @@ yield ugly NA and NaN statistics: ```{r} set.seed(1206) -q <- data.frame(p = rep(c("A","B"),each=10,len=30), - a = rep(c(1,2,3),each=10),id=seq(30), +q <- data.frame(p = rep(c("A","B"), each = 10, length.out = 30), + a = rep(c(1,2,3),each = 10),id = seq(30), b = round(runif(30,10,20)), c = round(runif(30,40,70)), stringsAsFactors = FALSE) diff --git a/vignettes/tables.Rnw b/vignettes/tables.Rnw index fba6007..6710c04 100644 --- a/vignettes/tables.Rnw +++ b/vignettes/tables.Rnw @@ -148,7 +148,7 @@ For the examples below we use the following definitions: set.seed(100) X <- rnorm(10) X -A <- sample(letters[1:2], 10, rep=TRUE) +A <- sample(letters[1:2], 10, replace = TRUE) A F <- factor(A) F @@ -1238,7 +1238,7 @@ yield ugly NA and NaN statistics: \begin{center} <>= set.seed(1206) -q <- data.frame(p = rep(c("A","B"),each=10,len=30), +q <- data.frame(p = rep(c("A","B"), each = 10, length.out = 30), a = rep(c(1,2,3),each=10),id=seq(30), b = round(runif(30,10,20)), c = round(runif(30,40,70)), diff --git a/vignettes/tables.Rout.save b/vignettes/tables.Rout.save index 88eb83b..fcc8930 100644 --- a/vignettes/tables.Rout.save +++ b/vignettes/tables.Rout.save @@ -68,7 +68,7 @@ All & $150$ & $5.84$ & $0.83$ & $3.06$ & $0.44$ \\ [5] 0.11697127 0.31863009 -0.58179068 0.71453271 [9] -0.82525943 -0.35986213 -> A <- sample(letters[1:2], 10, rep = TRUE) +> A <- sample(letters[1:2], 10, replace = TRUE) > A [1] "b" "b" "b" "b" "a" "a" "b" "b" "b" "a" @@ -861,9 +861,9 @@ All & $4$ \\ > set.seed(1206) -> q <- data.frame(p = rep(c("A", "B"), each = 10, len = 30), +> q <- data.frame(p = rep(c("A", "B"), each = 10, length.out = 30), + a = rep(c(1, 2, 3), each = 10), id = seq(30), b = round(runif(30, -+ 10, 2 .... [TRUNCATED] ++ .... [TRUNCATED] > tab <- tabular((Factor(p) * Factor(a) + 1) ~ (N = 1) + + (b + c) * (mean + sd), data = q) @@ -983,4 +983,4 @@ All & $150$ & $5.84$ & $0.83$ & $3.06$ & $0.44$ \\ *** Run successfully completed *** > proc.time() user system elapsed - 2.642 0.138 2.798 + 0.688 0.030 0.718