Skip to content

Commit

Permalink
Don't use argument abbreviations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmurdoch committed Aug 22, 2024
1 parent 376e404 commit db12285
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions R/tabular.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
6 changes: 3 additions & 3 deletions man/Percent.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
Expand Down
2 changes: 1 addition & 1 deletion man/html.tabular.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
Expand Down
4 changes: 2 additions & 2 deletions man/matrix_form.tabular.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions man/tabular.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/HTML.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions vignettes/knitrTables.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions vignettes/tables.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1238,7 +1238,7 @@ yield ugly NA and NaN statistics:
\begin{center}
<<results=tex>>=
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)),
Expand Down
8 changes: 4 additions & 4 deletions vignettes/tables.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit db12285

Please sign in to comment.