Skip to content

Commit

Permalink
fixed docs and args to be consistent with CRAN. no feature change
Browse files Browse the repository at this point in the history
  • Loading branch information
kaz-yos committed Feb 9, 2014
1 parent 53619f8 commit 0fcfbca
Show file tree
Hide file tree
Showing 19 changed files with 403 additions and 545 deletions.
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ Type: Package
Title: Create the "Table 1" to describe baseline characteristics
Version: 0.1.1
Date: 2014-02-09
Author: Kazuki Yoshida (based on Deducer by Ian Fellows)
Author: Kazuki Yoshida
Maintainer: Kazuki Yoshida <[email protected]>
Description: For some reasons, there are no good functions to create the "Table
Description: This package creates create the "Table
1", i.e., description of baseline characteristics in R although it is
essential in every medical research. The package was insipired by
descriptive statistics functions in Deducer, Java-based GUI package. This
package does not require GUI or Java, and intended for CUI users.
License: GPL-2
Depends:
e1071,
gmodels
gmodels,
survival
URL: https://github.com/kaz-yos/tableone
8 changes: 7 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
exportPattern("^[[:alpha:]]+")
export(CreateCatTable)
export(CreateContTable)
export(ShowRegTable)
export(print.CatTable)
export(print.ContTable)
export(summary.CatTable)
export(summary.ContTable)
8 changes: 0 additions & 8 deletions R/CatTable-class.R

This file was deleted.

22 changes: 0 additions & 22 deletions R/ContTable-class.R

This file was deleted.

8 changes: 4 additions & 4 deletions R/CreateCatTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
##' also \code{\link{print.CatTable}} and \code{\link{summary.CatTable}}.
##'
##'
##' @usage CreateCatTable(vars, strata, data, test = TRUE, testApprox =
##' chisq.test, testExact = fisher.test)
## @usage CreateCatTable(vars, strata, data, test = TRUE, testApprox =

This comment has been minimized.

Copy link
@hadley

hadley Feb 9, 2014

You should never need to use @usage roxygen will generate automatically.

## chisq.test, testExact = fisher.test)
##' @param vars Variable(s) to be summarized given as a character vector.
##' @param strata Stratifying (grouping) variable name(s) given as a character
##' vector. If omitted, the overall results are returned.
Expand All @@ -24,8 +24,8 @@
##' fisher.test. If the cells have large numbers, it will fail because of
##' memory limitation. In this situation, the large sample approximation based
##' should suffice.
##' @return An object of class CatTable, which really is a ‘by’ object with
##' additional attributes. Each element of the ‘by’ part is a matrix with rows
##' @return An object of class \code{CatTable}, which really is a \code{\link{by}} object with
##' additional attributes. Each element of the \code{\link{by}} part is a matrix with rows
##' representing variables, and columns representing summary statistics.
##' @note Special Thanks:
##'
Expand Down
6 changes: 3 additions & 3 deletions R/CreateContTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
##' The default is kruskal.test (Kruskal-Wallis Rank Sum Test). This is
##' equivalent of the wilcox.test (Man-Whitney U test) when there are only two
##' groups.
##' @return An object of class ContTable, which really is a ‘by’ object with
##' additional attributes. Each element of the ‘by’ part is a matrix with rows
##' @return An object of class \code{ContTable}, which really is a \code{\link{by}} object with
##' additional attributes. Each element of the \code{\link{by}} part is a matrix with rows
##' representing variables, and columns representing summary statistics.
##' @note Special Thanks:
##'
Expand Down Expand Up @@ -119,7 +119,7 @@ CreateContTable <- function(vars, # vector of characters
testNonNormal = kruskal.test # test for nonnormally distributed variables
) {
## Require dependencies (DELETE before CRAN release. Use Depends in DESCRIPTION)
require(e1071) # for skewness and kurtosis
## require(e1071) # for skewness and kurtosis

## Check if the data given is a dataframe
if (is.data.frame(data) == FALSE) {
Expand Down
15 changes: 10 additions & 5 deletions R/print.CatTable.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##' Format and print the CatTable class objects
##' Format and print the \code{CatTable} class objects
##'
##' This is the print method for the CatTable class objects created by
##' CreateCatTable function.
Expand All @@ -8,7 +8,7 @@
## FALSE, format = c("fp", "f", "p", "pf")[1], digits = 1, exact = NULL, quote
## = FALSE, test = TRUE, pDigits = 3, showAllLevels = FALSE, explain = TRUE,
## CrossTable = FALSE)
##' @param CatTable The result of a call to the CreateCatTable function.
##' @param x The result of a call to the \code{\link{CreateCatTable}} function.
##' @param missing Whether to show missing data information (not implemented
##' yet, placeholder)
##' @param format The default is "fp" frequency (percentage). You can also
Expand All @@ -31,6 +31,8 @@
##' @param CrossTable Whether to show the cross table objects held internally
##' using gmodels::CrossTable function. This will give an output similar to the
##' PROC FREQ in SAS.
##' @param ... Additional arguments. Required for the generic print(x, ...).
##' (not implemented yet, placeholder)
##' @return It is mainly for printing the result. But this function does return
##' a matrix containing what you see in the output invisibly. You can assign it
##' to an object to save it.
Expand Down Expand Up @@ -100,14 +102,17 @@
##' print(catTableBySexTrt, exact = "ascites", quote = TRUE)
##'
##' @export print.CatTable
print.CatTable <- function(CatTable, missing = FALSE,
print.CatTable <- function(x, missing = FALSE,
format = c("fp","f","p","pf")[1], # Format f_requency and/or p_ercent
digits = 1, exact = NULL, quote = FALSE,
test = TRUE, pDigits = 3,
showAllLevels = FALSE,
explain = TRUE,
CrossTable = FALSE) {
CrossTable = FALSE, ...) {

## x and ... required to be consistent with generic print(x, ...)
CatTable <- x

### Check the data structure first

## CatTable has a strata(list)-variable(list)-table(dataframe) structure
Expand Down Expand Up @@ -445,7 +450,7 @@ print.CatTable <- function(CatTable, missing = FALSE,
if (CrossTable) {

## DELETE before CRAN release (Use Depends in DESCRIPTION instead)
require(gmodels)
## require(gmodels)

junk <- lapply(attributes(CatTable)$xtabs, CrossTable)
}
Expand Down
14 changes: 9 additions & 5 deletions R/print.ContTable.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
##' Format and print the ContTable class objects
##' Format and print the \code{ContTable} class objects
##'
##' This is the print method for the ContTable class objects created by
##' CreateContTable function.
##'
##'
## @usage print.ContTable(ContTable, missing = FALSE, digits = 2, nonnormal =
## NULL, quote = FALSE, test = TRUE, pDigits = 3, explain = TRUE)
##' @param ContTable The result of a call to the CreateContTable function.
##' @param x The result of a call to the \code{\link{CreateContTable}} function.
##' @param missing Whether to show missing data information (not implemented
##' yet, placeholder)
##' @param digits Number of digits to print in the table.
Expand All @@ -21,6 +21,8 @@
##' @param pDigits Number of digits to print for p-values.
##' @param explain Whether to add explanation to the variable names, i.e.,
##' (mean (sd) or median [IQR]) is added to the variable names.
##' @param ... Additional arguments. Required for the generic print(x, ...).

This comment has been minimized.

Copy link
@hadley

hadley Feb 9, 2014

Just say: "For compatibility with generic, ignored`

##' (not implemented yet, placeholder)
##' @return It is mainly for printing the result. But this function does return
##' a matrix containing what you see in the output invisibly. You can assign it
##' to an object to save it.
Expand Down Expand Up @@ -88,12 +90,14 @@
##' print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE)
##'
##' @export print.ContTable

This comment has been minimized.

Copy link
@hadley

hadley Feb 9, 2014

You should just use @export and roxygen will generate the correct namespace export. You should be exporting the function as a S3 method.

print.ContTable <- function(ContTable, missing = FALSE,
print.ContTable <- function(x, missing = FALSE,
digits = 2, nonnormal = NULL, quote = FALSE,
test = TRUE, pDigits = 3,
explain = TRUE
) {
explain = TRUE, ...) {

## x and ... required to be consistent with generic print(x, ...)
ContTable <- x

### Check data structure first

## ContTable is by() object
Expand Down
11 changes: 8 additions & 3 deletions R/summary.CatTable.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##' Shows all results in a CatTable class object
##' Shows all results in a \code{CatTable} class object
##'
##' This method shows all the data a CatTable class object has. This includes
##' the (optionally stratified) part with summary statistics and p-values from
Expand All @@ -7,8 +7,10 @@
##'
##'
## @usage summary.CatTable(CatTable, digits = 1)
##' @param CatTable An object that has the CatTable class to be shown.
##' @param object An object that has the \code{CatTable} class to be shown.
##' @param digits Number of digits to print.
##' @param ... Additional arguments. Required for the generic summary(object, ...).
##' (not implemented yet, placeholder)
##' @return It will print the results.
##' @note Special Thanks:
##'
Expand Down Expand Up @@ -48,8 +50,11 @@
##' summary(catTableOverall)
##'
##' @export summary.CatTable
summary.CatTable <- function(CatTable, digits = 1) {
summary.CatTable <- function(object, digits = 1, ...) {

## object and ... required to be consistent with generic summary(object, ...)
CatTable <- object

## Create format
fmt <- paste0("%.", digits, "f")

Expand Down
16 changes: 9 additions & 7 deletions R/summary.ContTable.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
##' Shows all results in a ContTable class object
##' Shows all results in a \code{ContTable} class object
##'
##' This method shows all the data a ContTable class object has. This includes
##' This method shows all the data a \code{ContTable} class object has. This includes
##' the (optionally stratified) part with summary statistics and p-values from
##' the normal assupmtion-based test (oneway.test by default) and nonparametric
##' test (kruskal.test by default).
##'
##'
## @usage summary.ContTable(ContTable, digits = 2)
##' @param ContTable An object that has the ContTable class to be shown.
##' @param object An object that has the \code{ContTable} class to be shown.
##' @param digits Number of digits to print.
##' @param ... Additional arguments. Required for the generic summary(object, ...).
##' (not implemented yet, placeholder)
##' @return It will print the results.
##' @note Special Thanks:
##'
Expand Down Expand Up @@ -48,14 +50,14 @@
##' summary(contTableOverall)
##'
##' @export summary.ContTable
summary.ContTable <- function(ContTable, digits = 2) {
summary.ContTable <- function(object, digits = 2, ...) {

## Just call print.by
print.by(ContTable, digits = digits)
print.by(object, digits = digits)

## Print p-values if it exist
if (!is.null(attributes(ContTable)$pValues)) {
if (!is.null(attributes(object)$pValues)) {
cat("\np-values\n")
print(attributes(ContTable)$pValues)
print(attributes(object)$pValues)
}
}
11 changes: 6 additions & 5 deletions R/tableone-package.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
##' Create the Table 1 to describe baseline characteristics
##' Create "Table 1" to describe baseline characteristics
##'
##' For some reasons, there are no good functions to create the Table 1, i.e.,
##' description of baseline characteristics in R although it is essential in
##' every medical research. The package was insipired by descriptive statistics
##' Table 1, i.e., description of baseline patient characteristics is essential
##' every medical research. This package provides functions to create such
##' summaries for continuous and categorical variables, optionally with subgroups
##' and groupwise comparison. The package was insipired by descriptive statistics
##' functions in Deducer, Java-based GUI package. This package does not require
##' GUI or Java, and intended for CUI users.
##'
##' \tabular{ll}{ Package: \tab tableone\cr Type: \tab Package\cr Version: \tab
##' 0.1.0\cr Date: \tab 2014-02-08\cr License: \tab GPL-2\cr } Create an object
##' 0.1.1\cr Date: \tab 2014-02-08\cr License: \tab GPL-2\cr } Create an object
##' summarizing continous and categorical variables optionally stratifying by
##' one or more startifying variables and performing statistical tests. The
##' object gives a table that is easy to use in medical research papers.
Expand Down
Loading

0 comments on commit 0fcfbca

Please sign in to comment.