Skip to content

Commit

Permalink
Merge branch 'rc0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
kaz-yos committed Apr 22, 2014
2 parents 8d95e58 + 760a7bf commit 1bc2c38
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: tableone
Type: Package
Title: Create "Table 1" to describe baseline characteristics
Version: 0.4.0
Date: 2014-03-30
Version: 0.5.0
Date: 2014-04-14
Author: Kazuki Yoshida, Justin Bohn.
Maintainer: Kazuki Yoshida <[email protected]>
Description: This package creates "Table 1", i.e., description of baseline
Expand Down
10 changes: 10 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
tableone 0.5.0 (2014-04-14)
----------------------------------------------------------------

NEW FEATURES

* The noSpaces argument was added to print.* functions. This allows
removal of spaces added for alignment using fixed-width fonts.
Use this option if you prefer to align your table in other software.


tableone 0.4.0 (2014-03-30)
----------------------------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions R/CreateCatTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
##' ## Excel does not mess up the cells.
##' print(catTableBySexTrt, exact = "ascites", quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(catTableBySexTrt, exact = "ascites", quote = TRUE, noSpaces = TRUE)
##'
##' @export
CreateCatTable <-
function(vars, # character vector of variable names
Expand Down
3 changes: 3 additions & 0 deletions R/CreateContTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
##' ## Excel does not mess up the cells.
##' print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE, noSpaces = TRUE)
##'
##' @export
CreateContTable <-
function(vars, # character vector of variable names
Expand Down
4 changes: 4 additions & 0 deletions R/CreateTableOne.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
##' print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
##' exact = c("status","stage"), quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
##' exact = c("status","stage"), quote = TRUE, noSpaces = TRUE)
##'
##' @export
CreateTableOne <-
function(vars, # character vector of variable names
Expand Down
14 changes: 14 additions & 0 deletions R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ ModuleReturnDimHeaders <- function(TableObject) {
}


## Module to remove spaces from the result matrix
ModuleRemoveSpaces <- function(mat, noSpaces) {

## Carry out these replacements to remove spaces if asked
if (noSpaces) {
mat <- gsub(pattern = "^ *| *$", replacement = "", x = mat)
mat <- gsub(pattern = "\\( *", replacement = "(", x = mat)
}

## Return the matrix
mat
}


### Modules by both print and summary methods
## ModuleQuoteAndPrintMat()
## Takes an matrix object format, print, and (invisibly) return it
Expand Down
8 changes: 8 additions & 0 deletions R/print.CatTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
##' @param missing Whether to show missing data information (not implemented yet, placeholder)
##' @param explain Whether to add explanation to the variable names, i.e., (\%) is added to the variable names when percentage is shown.
##' @param printToggle Whether to print the output. If FLASE, no output is created, and a matrix is invisibly returned.
##' @param noSpaces Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software.
##' @param format The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency).
##' @param showAllLevels Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information.
##' @param cramVars A character vector to specify the two-level categorical variables, for which both levels should be shown in one row.
Expand Down Expand Up @@ -78,6 +79,9 @@
##' ## Excel does not mess up the cells.
##' print(catTableBySexTrt, exact = "ascites", quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(catTableBySexTrt, exact = "ascites", quote = TRUE, noSpaces = TRUE)
##'
##' @export
print.CatTable <- function(x, # CatTable object
digits = 1, pDigits = 3, # Number of digits to show
Expand All @@ -86,6 +90,7 @@ print.CatTable <- function(x, # CatTable object
missing = FALSE, # Show missing values (not implemented yet)
explain = TRUE, # Whether to show explanation in variable names
printToggle = TRUE, # Whether to print the result visibly
noSpaces = FALSE, # Whether to remove spaces for alignments

format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent
showAllLevels = FALSE,
Expand Down Expand Up @@ -421,6 +426,9 @@ print.CatTable <- function(x, # CatTable object
## Add stratification information to the column header depending on the dimension
names(dimnames(out)) <- ModuleReturnDimHeaders(CatTable)

## Remove spaces if asked.
out <- ModuleRemoveSpaces(mat = out, noSpaces = noSpaces)

## Modular version of quote/print toggle.
out <- ModuleQuoteAndPrintMat(matObj = out,
quote = quote, printToggle = printToggle)
Expand Down
8 changes: 8 additions & 0 deletions R/print.ContTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
##' @param missing Whether to show missing data information (not implemented yet, placeholder)
##' @param explain Whether to add explanation to the variable names, i.e., (mean (sd) or median [IQR]) is added to the variable names.
##' @param printToggle Whether to print the output. If FLASE, no output is created, and a matrix is invisibly returned.
##' @param noSpaces Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software.
##' @param nonnormal A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test).
##' @param minMax Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE.
##' @param insertLevel Whether to add an empty level column to the left of strata.
Expand Down Expand Up @@ -77,6 +78,9 @@
##' ## Excel does not mess up the cells.
##' print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE, noSpaces = TRUE)
##'
##' @export
print.ContTable <- function(x, # ContTable object
digits = 2, pDigits = 3, # Number of digits to show
Expand All @@ -85,6 +89,7 @@ print.ContTable <- function(x, # ContTable object
missing = FALSE, # show missing values (not implemented yet)
explain = TRUE, # Whether to show explanation in variable names
printToggle = TRUE, # Whether to print the result visibly
noSpaces = FALSE, # Whether to remove spaces for alignments

nonnormal = NULL, # Which variables should be treated as nonnormal
minMax = FALSE, # median [range] instead of median [IQR]
Expand Down Expand Up @@ -297,6 +302,9 @@ print.ContTable <- function(x, # ContTable object
## Add stratification information to the column header depending on the dimension
names(dimnames(out)) <- ModuleReturnDimHeaders(ContTable)

## Remove spaces if asked.
out <- ModuleRemoveSpaces(mat = out, noSpaces = noSpaces)

## (module) Takes an matrix object format, print if requested
out <- ModuleQuoteAndPrintMat(matObj = out,
quote = quote, printToggle = printToggle)
Expand Down
15 changes: 15 additions & 0 deletions R/print.TableOne.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
##' @param explain Whether to add explanation to the variable names, i.e., (\%) is added to the variable names when percentage is shown.
##' @param printToggle Whether to print the output. If FLASE, no output is created, and a matrix is invisibly returned.
##' @param test Whether to show the p-values. TRUE by default. If FALSE, only the numerical summaries are shown.
##' @param noSpaces Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software.
##' @param format The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency).
##' @param showAllLevels Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information.
##' @param cramVars A character vector to specify the two-level categorical variables, for which both levels should be shown in one row.
Expand Down Expand Up @@ -66,6 +67,16 @@
##' ## See the continuous part only using $ operator
##' tableOne$ContTable
##' summary(tableOne$ContTable)
##'
##' ## If your work flow includes copying to Excel and Word when writing manuscripts,
##' ## you may benefit from the quote argument. This will quote everything so that
##' ## Excel does not mess up the cells.
##' print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
##' exact = c("status","stage"), cramVars = "hepato", quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
##' exact = c("status","stage"), cramVars = "hepato", quote = TRUE, noSpaces = TRUE)
##'
##' @export
print.TableOne <- function(x, # TableOne object
Expand All @@ -77,6 +88,7 @@ print.TableOne <- function(x, # TableOne object
explain = TRUE, # Whether to show explanation in variable names
printToggle = TRUE, # Whether to print the result visibly
test = TRUE, # Whether to add p-values
noSpaces = FALSE, # Whether to remove spaces for alignments

## Categorical options
format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent
Expand Down Expand Up @@ -199,6 +211,9 @@ print.TableOne <- function(x, # TableOne object
names(dimnames(out)) <- c("", "")
}

## Remove spaces if asked.
out <- ModuleRemoveSpaces(mat = out, noSpaces = noSpaces)

## Modular version of quote/print toggle.
out <- ModuleQuoteAndPrintMat(matObj = out,
quote = quote, printToggle = printToggle)
Expand Down
4 changes: 4 additions & 0 deletions R/tableone-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@
##' print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
##' exact = c("status","stage"), cramVars = "sex", quote = TRUE)
##'
##' ## If you want to center-align values in Word, use noSpaces option.
##' print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
##' exact = c("status","stage"), cramVars = "sex", quote = TRUE, noSpaces = TRUE)
##'
NULL
3 changes: 3 additions & 0 deletions man/CreateCatTable.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ summary(catTableBySexTrt)
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(catTableBySexTrt, exact = "ascites", quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(catTableBySexTrt, exact = "ascites", quote = TRUE, noSpaces = TRUE)
}
\author{
Kazuki Yoshida (based on \code{Deducer::frequencies()})
Expand Down
3 changes: 3 additions & 0 deletions man/CreateContTable.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ summary(contTableBySexTrt)
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE, noSpaces = TRUE)
}
\author{
Kazuki Yoshida (based on
Expand Down
4 changes: 4 additions & 0 deletions man/CreateTableOne.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ summary(tableOne$ContTable)
## Excel does not mess up the cells.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), quote = TRUE, noSpaces = TRUE)
}
\author{
Justin Bohn, Kazuki Yoshida
Expand Down
13 changes: 10 additions & 3 deletions man/print.CatTable.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
\title{Format and print the \code{CatTable} class objects}
\usage{
\method{print}{CatTable}(x, digits = 1, pDigits = 3, quote = FALSE,
missing = FALSE, explain = TRUE, printToggle = TRUE, format = c("fp",
"f", "p", "pf")[1], showAllLevels = FALSE, cramVars = NULL, test = TRUE,
exact = NULL, CrossTable = FALSE, ...)
missing = FALSE, explain = TRUE, printToggle = TRUE, noSpaces = FALSE,
format = c("fp", "f", "p", "pf")[1], showAllLevels = FALSE,
cramVars = NULL, test = TRUE, exact = NULL, CrossTable = FALSE, ...)
}
\arguments{
\item{x}{The result of a call to the
Expand All @@ -31,6 +31,10 @@
no output is created, and a matrix is invisibly
returned.}

\item{noSpaces}{Whether to remove spaces added for
alignment. Use this option if you prefer to align numbers
yourself in other software.}

\item{format}{The default is "fp" frequency (percentage).
You can also choose from "f" frequency only, "p"
percentage only, and "pf" percentage (frequency).}
Expand Down Expand Up @@ -123,6 +127,9 @@ summary(catTableBySexTrt)
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(catTableBySexTrt, exact = "ascites", quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(catTableBySexTrt, exact = "ascites", quote = TRUE, noSpaces = TRUE)
}
\author{
Kazuki Yoshida
Expand Down
12 changes: 10 additions & 2 deletions man/print.ContTable.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
\title{Format and print the \code{ContTable} class objects}
\usage{
\method{print}{ContTable}(x, digits = 2, pDigits = 3, quote = FALSE,
missing = FALSE, explain = TRUE, printToggle = TRUE, nonnormal = NULL,
minMax = FALSE, insertLevel = FALSE, test = TRUE, ...)
missing = FALSE, explain = TRUE, printToggle = TRUE, noSpaces = FALSE,
nonnormal = NULL, minMax = FALSE, insertLevel = FALSE, test = TRUE,
...)
}
\arguments{
\item{x}{The result of a call to the
Expand All @@ -30,6 +31,10 @@
no output is created, and a matrix is invisibly
returned.}

\item{noSpaces}{Whether to remove spaces added for
alignment. Use this option if you prefer to align numbers
yourself in other software.}

\item{nonnormal}{A character vector to specify the
variables for which the p-values should be those of
nonparametric tests. By default all p-values are from
Expand Down Expand Up @@ -112,6 +117,9 @@ summary(contTableBySexTrt)
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE, noSpaces = TRUE)
}
\author{
Kazuki Yoshida
Expand Down
19 changes: 17 additions & 2 deletions man/print.TableOne.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
\usage{
\method{print}{TableOne}(x, catDigits = 1, contDigits = 2, pDigits = 3,
quote = FALSE, missing = FALSE, explain = TRUE, printToggle = TRUE,
test = TRUE, format = c("fp", "f", "p", "pf")[1], showAllLevels = FALSE,
cramVars = NULL, exact = NULL, nonnormal = NULL, minMax = FALSE, ...)
test = TRUE, noSpaces = FALSE, format = c("fp", "f", "p", "pf")[1],
showAllLevels = FALSE, cramVars = NULL, exact = NULL,
nonnormal = NULL, minMax = FALSE, ...)
}
\arguments{
\item{x}{The result of a call to the
Expand Down Expand Up @@ -40,6 +41,10 @@
default. If FALSE, only the numerical summaries are
shown.}

\item{noSpaces}{Whether to remove spaces added for
alignment. Use this option if you prefer to align numbers
yourself in other software.}

\item{format}{The default is "fp" frequency (percentage).
You can also choose from "f" frequency only, "p"
percentage only, and "pf" percentage (frequency).}
Expand Down Expand Up @@ -119,6 +124,16 @@ summary(tableOne$CatTable)
## See the continuous part only using $ operator
tableOne$ContTable
summary(tableOne$ContTable)

## If your work flow includes copying to Excel and Word when writing manuscripts,
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), cramVars = "hepato", quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), cramVars = "hepato", quote = TRUE, noSpaces = TRUE)
}
\author{
Kazuki Yoshida, Justin Bohn
Expand Down
4 changes: 4 additions & 0 deletions man/tableone-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ summary(tableOne$ContTable)
## Excel does not mess up the cells.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), cramVars = "sex", quote = TRUE)

## If you want to center-align values in Word, use noSpaces option.
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), cramVars = "sex", quote = TRUE, noSpaces = TRUE)
}
\author{
Kazuki Yoshida, Justin Bohn
Expand Down

0 comments on commit 1bc2c38

Please sign in to comment.