diff --git a/DESCRIPTION b/DESCRIPTION index 786921b..ca504eb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,9 +3,9 @@ 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 -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 @@ -13,4 +13,6 @@ Description: For some reasons, there are no good functions to create the "Table License: GPL-2 Depends: e1071, - gmodels + gmodels, + survival +URL: https://github.com/kaz-yos/tableone diff --git a/NAMESPACE b/NAMESPACE index d75f824..7dae9c0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1 +1,7 @@ -exportPattern("^[[:alpha:]]+") +export(CreateCatTable) +export(CreateContTable) +export(ShowRegTable) +export(print.CatTable) +export(print.ContTable) +export(summary.CatTable) +export(summary.ContTable) diff --git a/R/CatTable-class.R b/R/CatTable-class.R deleted file mode 100644 index 97ce44c..0000000 --- a/R/CatTable-class.R +++ /dev/null @@ -1,8 +0,0 @@ -################################################################################ -### Definition for CatTable class -## -## Created on: 2014-02-08 -## Author: Kazuki Yoshida -################################################################################ - - diff --git a/R/ContTable-class.R b/R/ContTable-class.R deleted file mode 100644 index 605aec3..0000000 --- a/R/ContTable-class.R +++ /dev/null @@ -1,22 +0,0 @@ -################################################################################ -### Definition for ContTable class -## -## Created on: 2014-02-08 -## Author: Kazuki Yoshida -################################################################################ - - - - - - - - - - - - - - - - diff --git a/R/CreateCatTable.R b/R/CreateCatTable.R index 6b9dcb9..8026e0e 100644 --- a/R/CreateCatTable.R +++ b/R/CreateCatTable.R @@ -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 = +## 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. @@ -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: ##' diff --git a/R/CreateContTable.R b/R/CreateContTable.R index a23f489..c9fdab9 100644 --- a/R/CreateContTable.R +++ b/R/CreateContTable.R @@ -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: ##' @@ -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) { diff --git a/R/print.CatTable.R b/R/print.CatTable.R index 19f8521..a8c8958 100644 --- a/R/print.CatTable.R +++ b/R/print.CatTable.R @@ -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. @@ -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 @@ -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. @@ -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 @@ -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) } diff --git a/R/print.ContTable.R b/R/print.ContTable.R index 7f579b3..fef0d49 100644 --- a/R/print.ContTable.R +++ b/R/print.ContTable.R @@ -1,4 +1,4 @@ -##' 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. @@ -6,7 +6,7 @@ ##' ## @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. @@ -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, ...). +##' (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. @@ -88,12 +90,14 @@ ##' print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE) ##' ##' @export print.ContTable -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 diff --git a/R/summary.CatTable.R b/R/summary.CatTable.R index 7de8e21..9cbc921 100644 --- a/R/summary.CatTable.R +++ b/R/summary.CatTable.R @@ -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 @@ -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: ##' @@ -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") diff --git a/R/summary.ContTable.R b/R/summary.ContTable.R index acae2e1..6eddbd0 100644 --- a/R/summary.ContTable.R +++ b/R/summary.ContTable.R @@ -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: ##' @@ -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) } } diff --git a/R/tableone-package.R b/R/tableone-package.R index 87da731..e53130e 100644 --- a/R/tableone-package.R +++ b/R/tableone-package.R @@ -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. diff --git a/man/CreateCatTable.Rd b/man/CreateCatTable.Rd index c0789f4..b381158 100644 --- a/man/CreateCatTable.Rd +++ b/man/CreateCatTable.Rd @@ -1,77 +1,64 @@ \name{CreateCatTable} \alias{CreateCatTable} -\title{ - Create an object summarizing categorical variables -} -\description{ - Create an object summarizing 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. See also print.CatTable and summary.CatTable. - -} +\title{Create an object summarizing categorical variables} \usage{ CreateCatTable(vars, strata, data, test = TRUE, testApprox = chisq.test, - testExact = fisher.test) + testExact = fisher.test) } \arguments{ - \item{vars}{ - Variable(s) to be summarized given as a character vector. -} - \item{strata}{ - Stratifying (grouping) variable name(s) given as a character - vector. If omitted, the overall results are returned. -} - \item{data}{ - A data frame in which these variables exist. All variables (both - vars and strata) must be in this data frame. -} - \item{test}{ - If TRUE, as in the default and there are more than two groups, - groupwise comparisons are performed. Both tests that require the - large sample approximation and exact tests are performed. Either one - of the result can be obtained from the print method. -} - \item{testApprox}{ - A function used to perform the large sample approximation based - tests. The default is chisq.test. This is not recommended when some - of the cell have small counts like fewer than 5. -} - \item{testExact}{ - A function used to perform the exact tests. The default is - 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. -} -} -\details{ + \item{vars}{Variable(s) to be summarized given as a + character vector.} + + \item{strata}{Stratifying (grouping) variable name(s) + given as a character vector. If omitted, the overall + results are returned.} + + \item{data}{A data frame in which these variables exist. + All variables (both vars and strata) must be in this data + frame.} + + \item{test}{If TRUE, as in the default and there are more + than two groups, groupwise comparisons are performed. + Both tests that require the large sample approximation + and exact tests are performed. Either one of the result + can be obtained from the print method.} + + \item{testApprox}{A function used to perform the large + sample approximation based tests. The default is + chisq.test. This is not recommended when some of the cell + have small counts like fewer than 5.} + + \item{testExact}{A function used to perform the exact + tests. The default is 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.} } \value{ -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 representing variables, and columns representing summary statistics. +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. } -\references{ -} -\author{ - Kazuki YOSHIDA +\description{ +Create an object summarizing 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. See also +\code{\link{print.CatTable}} and +\code{\link{summary.CatTable}}. } \note{ - Special Thanks: - - This package was inspired by and based on the Deducer package - (frequencies function). - - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} +Special Thanks: +This package was inspired by and based on the Deducer +package (frequencies function). -\seealso{ - print.CatTable, summary.CatTable, CreateContTable, print.ContTable, - summary.ContTable +Developmental repository is on github. Your contributions +are appreciated. + +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -126,5 +113,11 @@ summary(catTableBySexTrt) ## Excel does not mess up the cells. print(catTableBySexTrt, exact = "ascites", quote = TRUE) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki YOSHIDA +} +\seealso{ +print.CatTable, summary.CatTable, CreateContTable, +print.ContTable, summary.ContTable +} + diff --git a/man/CreateContTable.Rd b/man/CreateContTable.Rd index b331c30..336f1e0 100644 --- a/man/CreateContTable.Rd +++ b/man/CreateContTable.Rd @@ -1,89 +1,75 @@ \name{CreateContTable} \alias{CreateContTable} -\title{ - Create an object summarizing continous variables -} -\description{ - Create an object summarizing continous 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. -} +\title{Create an object summarizing continous variables} \usage{ -CreateContTable(vars, strata, data, func.names = c("n", "miss", "mean", - "sd", "median", "p25", "p75", "min", "max", "skew", - "kurt"), func.additional, test = TRUE, - testNormal = oneway.test, testNonNormal = kruskal.test) +CreateContTable(vars, strata, data, func.names = c("n", "miss", "mean", "sd", + "median", "p25", "p75", "min", "max", "skew", "kurt"), func.additional, + test = TRUE, testNormal = oneway.test, testNonNormal = kruskal.test) } \arguments{ - \item{vars}{ - Variable(s) to be summarized given as a character vector. -} - \item{strata}{ - Stratifying (grouping) variable name(s) given as a character - vector. If omitted, the overall results are returned. -} - \item{data}{ - A data frame in which these variables exist. All variables (both - vars and strata) must be in this data frame. -} - \item{func.names}{ - The functions to give the group size, number with missing values, - mean, standard deviations, median, 25th percentile, 75th percentile, - minimum, maximum, skewness (same definition as in SAS), kurtosis - (same definition as in SAS). All of them can be seen in the summary - method output. The print method uses subset of these. You can choose - subset of them or reorder them. They are all configure to omit NA - values (na.rm = TRUE). -} - \item{func.additional}{ - Additional functions can be given as a named list. For example, - list(sum = sum). -} - \item{test}{ - If TRUE, as in the default and there are more than two groups, - groupwise comparisons are performed. Both tests that assume normality - and tests that do not are performed. Either one of the result can be - obtained from the print method. -} - \item{testNormal}{ - A function used to perform the normal assumption based tests. The - default is oneway.test. This is equivalent of the t-test with - unequal variance when there are only two groups. -} - \item{testNonNormal}{ - A function used to perform the nonparametric tests. 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. -} -} -\details{ + \item{vars}{Variable(s) to be summarized given as a + character vector.} + + \item{strata}{Stratifying (grouping) variable name(s) + given as a character vector. If omitted, the overall + results are returned.} + + \item{data}{A data frame in which these variables exist. + All variables (both vars and strata) must be in this data + frame.} + + \item{func.names}{The functions to give the group size, + number with missing values, mean, standard deviations, + median, 25th percentile, 75th percentile, minimum, + maximum, skewness (same definition as in SAS), kurtosis + (same definition as in SAS). All of them can be seen in + the summary method output. The print method uses subset + of these. You can choose subset of them or reorder them. + They are all configure to omit NA values (na.rm = TRUE).} + + \item{func.additional}{Additional functions can be given + as a named list. For example, list(sum = sum).} + + \item{test}{If TRUE, as in the default and there are more + than two groups, groupwise comparisons are performed. + Both tests that assume normality and tests that do not + are performed. Either one of the result can be obtained + from the print method.} + + \item{testNormal}{A function used to perform the normal + assumption based tests. The default is oneway.test. This + is equivalent of the t-test with unequal variance when + there are only two groups.} + + \item{testNonNormal}{A function used to perform the + nonparametric tests. 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.} } \value{ -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 representing variables, and columns representing summary statistics. +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. } -\references{ -} -\author{ - Kazuki YOSHIDA +\description{ +Create an object summarizing continous 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. } \note{ - Special Thanks: - - This package was inspired by and based on the Deducer package - (descriptive.table function). - - Developmental repository is on github. Your contributions are appreciated. - - https://github.com/kaz-yos/tableone -} +Special Thanks: +This package was inspired by and based on the Deducer +package (descriptive.table function). -\seealso{ - print.ContTable, summary.ContTable, CreateCatTable, print.CatTable, - summary.CatTable +Developmental repository is on github. Your contributions +are appreciated. + +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -136,5 +122,11 @@ summary(contTableBySexTrt) ## Excel does not mess up the cells. print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki YOSHIDA +} +\seealso{ +print.ContTable, summary.ContTable, CreateCatTable, +print.CatTable, summary.CatTable +} + diff --git a/man/ShowRegTable.Rd b/man/ShowRegTable.Rd index 0676dc1..8d2b895 100644 --- a/man/ShowRegTable.Rd +++ b/man/ShowRegTable.Rd @@ -1,57 +1,42 @@ \name{ShowRegTable} \alias{ShowRegTable} -\title{ - Format regression results in medically decent format -} -\description{ - It shows the regression result in the HR [95\% CI] p-value format, which is - usually the form used in medical research papers. -} +\title{Format regression results in medically decent format} \usage{ ShowRegTable(model, exp = TRUE, digits = 2, pDigits = 3, quote = FALSE) } \arguments{ - \item{model}{ - Regression model result objects that have the summary and confint methods. -} - \item{exp}{ - TRUE by default. You need to specify exp = FALSE if your model is - has the indentity link function (linear regression, etc). -} - \item{digits}{ - Number of digits to print for the main part. -} - \item{pDigits}{ - Number of digits to print for the p-values. -} - \item{quote}{ - Whether to show everything in quotes. The default is FALSE. If TRUE, - everything including the row and column names are quoted so that you - can copy it to Excel easily. -} -} -\details{ + \item{model}{Regression model result objects that have + the summary and confint methods.} + + \item{exp}{TRUE by default. You need to specify exp = + FALSE if your model is has the indentity link function + (linear regression, etc).} + + \item{digits}{Number of digits to print for the main + part.} + + \item{pDigits}{Number of digits to print for the + p-values.} + + \item{quote}{Whether to show everything in quotes. The + default is FALSE. If TRUE, everything including the row + and column names are quoted so that you can copy it to + Excel easily.} } \value{ -A matrix containing what you see is returned invisibly. You can capture -it by assignment to an object. -} -\references{ +A matrix containing what you see is returned invisibly. You +can capture it by assignment to an object. } -\author{ - Kazuki Yoshida +\description{ +It shows the regression result in the HR [95\% CI] p-value +format, which is usually the form used in medical research +papers. } \note{ - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} - +Developmental repository is on github. Your contributions +are appreciated. -\seealso{ - CreateContTable, print.ContTable, summary.ContTable, CreateCatTable, - print.CatTable, summary.CatTable +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -75,5 +60,11 @@ ShowRegTable(objCoxph) ## Show with quote to ease copy and paste ShowRegTable(objCoxph, quote = TRUE) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki Yoshida +} +\seealso{ +CreateContTable, print.ContTable, summary.ContTable, +CreateCatTable, print.CatTable, summary.CatTable +} + diff --git a/man/print.CatTable.Rd b/man/print.CatTable.Rd index d4b6289..0de534f 100644 --- a/man/print.CatTable.Rd +++ b/man/print.CatTable.Rd @@ -1,89 +1,75 @@ \name{print.CatTable} \alias{print.CatTable} -\title{ - Format and print the ‘CatTable’ class objects -} -\description{ - This is the print method for the CatTable class objects created by - CreateCatTable function. -} +\title{Format and print the \code{CatTable} class objects} \usage{ - ## S3 method for class 'CatTable' -print.CatTable(CatTable, missing = FALSE, format = c("fp", "f", "p", "pf")[1], digits = 1, exact = NULL, quote = FALSE, test = TRUE, pDigits = 3, showAllLevels = FALSE, explain = TRUE, CrossTable = FALSE) +\method{print}{CatTable}(x, missing = FALSE, format = c("fp", "f", "p", + "pf")[1], digits = 1, exact = NULL, quote = FALSE, test = TRUE, + pDigits = 3, showAllLevels = FALSE, explain = TRUE, + CrossTable = FALSE, ...) } \arguments{ - \item{CatTable}{ - The result of a call to the ‘CreateCatTable’ function. -} - \item{missing}{ - Whether to show missing data information (not implemented - yet, placeholder) -} - \item{format}{ - The default is "fp" frequency (percentage). You can also choose from - "f" frequency only, "p" percentage only, and "pf" percentage (frequency). -} - \item{digits}{ - Number of digits to print in the table. -} - \item{exact}{ - A character vector to specify the variables for which the p-values - should be those of exact tests. By default all p-values are from - large sample approximation tests (chisq.test). -} - \item{quote}{ - Whether to show everything in quotes. The default is FALSE. If TRUE, - everything including the row and column names are quoted so that you - can copy it to Excel easily. -} - \item{test}{ - Whether to show the p-values. TRUE by default. If FALSE, only the - numerical summaries are shown. -} - \item{pDigits}{ - Number of digits to print for p-values. -} - \item{showAllLevels}{ - Whether to show all levels. FALSE by default, i.e., for 2-level - categorical variables, only the higher level is shown to avoid -} - \item{explain}{ - Whether to add explanation to the variable names, i.e., (\%) is - added to the variable names when percentage is shown. -} - \item{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. -} -} -\details{ + \item{x}{The result of a call to the + \code{\link{CreateCatTable}} function.} + + \item{missing}{Whether to show missing data information + (not implemented yet, placeholder)} + + \item{format}{The default is "fp" frequency (percentage). + You can also choose from "f" frequency only, "p" + percentage only, and "pf" percentage (frequency).} + + \item{digits}{Number of digits to print in the table.} + + \item{exact}{A character vector to specify the variables + for which the p-values should be those of exact tests. By + default all p-values are from large sample approximation + tests (chisq.test).} + + \item{quote}{Whether to show everything in quotes. The + default is FALSE. If TRUE, everything including the row + and column names are quoted so that you can copy it to + Excel easily.} + + \item{test}{Whether to show the p-values. TRUE by + default. If FALSE, only the numerical summaries are + shown.} + + \item{pDigits}{Number of digits to print for p-values.} + + \item{showAllLevels}{Whether to show all levels. FALSE by + default, i.e., for 2-level categorical variables, only + the higher level is shown to avoid} + + \item{explain}{Whether to add explanation to the variable + names, i.e., (\%) is added to the variable names when + percentage is shown.} + + \item{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.} + + \item{...}{Additional arguments. Required for the generic + print(x, ...). (not implemented yet, placeholder)} } \value{ -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. +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. } -\references{ -} -\author{ - Kazuki YOSHIDA +\description{ +This is the print method for the CatTable class objects +created by CreateCatTable function. } \note{ - Special Thanks: - - This package was inspired by and based on the Deducer package - (frequencies function). - - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} +Special Thanks: +This package was inspired by and based on the Deducer +package (frequencies function). -\seealso{ - CreateCatTable, summary.CatTable, CreateContTable, print.ContTable, summary.ContTable +Developmental repository is on github. Your contributions +are appreciated. + +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -136,5 +122,11 @@ summary(catTableBySexTrt) ## Excel does not mess up the cells. print(catTableBySexTrt, exact = "ascites", quote = TRUE) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki YOSHIDA +} +\seealso{ +CreateCatTable, summary.CatTable, CreateContTable, +print.ContTable, summary.ContTable +} + diff --git a/man/print.ContTable.Rd b/man/print.ContTable.Rd index 731d67e..326994f 100644 --- a/man/print.ContTable.Rd +++ b/man/print.ContTable.Rd @@ -1,77 +1,62 @@ \name{print.ContTable} \alias{print.ContTable} -\title{ - Format and print the ‘ContTable’ class objects -} -\description{ - This is the print method for the ContTable class objects created by - CreateContTable function. -} +\title{Format and print the \code{ContTable} class objects} \usage{ -print.ContTable(ContTable, missing = FALSE, digits = 2, - nonnormal = NULL, quote = FALSE, test = TRUE, - pDigits = 3, explain = TRUE) +\method{print}{ContTable}(x, missing = FALSE, digits = 2, + nonnormal = NULL, quote = FALSE, test = TRUE, pDigits = 3, + explain = TRUE, ...) } \arguments{ - \item{ContTable}{ - The result of a call to the ‘CreateContTable’ function. -} - \item{missing}{ - Whether to show missing data information (not implemented - yet, placeholder) -} - \item{digits}{ - Number of digits to print in the table. -} - \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 - normal assumption-based tests (oneway.test). -} - \item{quote}{ - Whether to show everything in quotes. The default is FALSE. If TRUE, - everything including the row and column names are quoted so that you - can copy it to Excel easily. -} - \item{test}{ - Whether to show the p-values. TRUE by default. If FALSE, only the - numerical summaries are shown. -} - \item{pDigits}{ - Number of digits to print for p-values. -} - \item{explain}{ - Whether to add explanation to the variable names, i.e., (mean (sd) - or median [IQR]) is added to the variable names. -} -} -\details{ + \item{x}{The result of a call to the + \code{\link{CreateContTable}} function.} + + \item{missing}{Whether to show missing data information + (not implemented yet, placeholder)} + + \item{digits}{Number of digits to print in the table.} + + \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 + normal assumption-based tests (oneway.test).} + + \item{quote}{Whether to show everything in quotes. The + default is FALSE. If TRUE, everything including the row + and column names are quoted so that you can copy it to + Excel easily.} + + \item{test}{Whether to show the p-values. TRUE by + default. If FALSE, only the numerical summaries are + shown.} + + \item{pDigits}{Number of digits to print for p-values.} + + \item{explain}{Whether to add explanation to the variable + names, i.e., (mean (sd) or median [IQR]) is added to the + variable names.} + + \item{...}{Additional arguments. Required for the generic + print(x, ...). (not implemented yet, placeholder)} } \value{ -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. +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. } -\references{ -} -\author{ - Kazuki YOSHIDA +\description{ +This is the print method for the ContTable class objects +created by CreateContTable function. } \note{ - Special Thanks: - - This package was inspired by and based on the Deducer package - - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} +Special Thanks: +This package was inspired by and based on the Deducer +package -\seealso{ - CreateContTable, summary.ContTable, CreateCatTable, print.CatTable, - summary.CatTable +Developmental repository is on github. Your contributions +are appreciated. + +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -123,5 +108,11 @@ summary(contTableBySexTrt) ## Excel does not mess up the cells. print(contTableBySexTrt, nonnormal = nonNormalVars, quote = TRUE) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki YOSHIDA +} +\seealso{ +CreateContTable, summary.ContTable, CreateCatTable, +print.CatTable, summary.CatTable +} + diff --git a/man/summary.CatTable.Rd b/man/summary.CatTable.Rd index aab5ddc..0a37090 100644 --- a/man/summary.CatTable.Rd +++ b/man/summary.CatTable.Rd @@ -1,53 +1,38 @@ \name{summary.CatTable} \alias{summary.CatTable} -\title{ - Shows all results in a ‘CatTable’ class object -} -\description{ - This method shows all the data a CatTable class object has. This - includes the (optionally stratified) part with summary statistics and - p-values from the approximation method test (chisq.test by default) - and exact method test (fisher.test by default). - -} +\title{Shows all results in a \code{CatTable} class object} \usage{ -summary.CatTable(CatTable, digits = 1) +\method{summary}{CatTable}(object, digits = 1, ...) } \arguments{ - \item{CatTable}{ - An object that has the ‘CatTable’ class to be shown. -} - \item{digits}{ - Number of digits to print. -} -} -\details{ + \item{object}{An object that has the \code{CatTable} + class to be shown.} + + \item{digits}{Number of digits to print.} + + \item{...}{Additional arguments. Required for the generic + summary(object, ...). (not implemented yet, placeholder)} } \value{ It will print the results. } -\references{ -} -\author{ - Kazuki YOSHIDA +\description{ +This method shows all the data a CatTable class object has. +This includes the (optionally stratified) part with summary +statistics and p-values from the approximation method test +(chisq.test by default) and exact method test (fisher.test +by default). } \note{ - Special Thanks: - - This package was inspired by and based on the Deducer package - (frequencies function). - - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} +Special Thanks: +This package was inspired by and based on the Deducer +package (frequencies function). -\seealso{ - CreateCatTable, print.CatTable, CreateContTable, print.ContTable, - summary.ContTable - +Developmental repository is on github. Your contributions +are appreciated. + +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -72,5 +57,11 @@ catTableOverall ## which will show more details. summary(catTableOverall) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki YOSHIDA +} +\seealso{ +CreateCatTable, print.CatTable, CreateContTable, +print.ContTable, summary.ContTable +} + diff --git a/man/summary.ContTable.Rd b/man/summary.ContTable.Rd index d74c5ca..68d5be2 100644 --- a/man/summary.ContTable.Rd +++ b/man/summary.ContTable.Rd @@ -1,51 +1,38 @@ \name{summary.ContTable} \alias{summary.ContTable} -\title{ - Shows all results in a ‘ContTable’ class object -} -\description{ - This method shows all the data a 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). -} +\title{Shows all results in a \code{ContTable} class object} \usage{ -summary.ContTable(ContTable, digits = 2) +\method{summary}{ContTable}(object, digits = 2, ...) } \arguments{ - \item{ContTable}{ - An object that has the ‘ContTable’ class to be shown. -} - \item{digits}{ - Number of digits to print. -} -} -\details{ + \item{object}{An object that has the \code{ContTable} + class to be shown.} + + \item{digits}{Number of digits to print.} + + \item{...}{Additional arguments. Required for the generic + summary(object, ...). (not implemented yet, placeholder)} } \value{ It will print the results. } -\references{ -} -\author{ - Kazuki YOSHIDA +\description{ +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). } \note{ - Special Thanks: - - This package was inspired by and based on the Deducer package - (descriptive.table function). - - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} +Special Thanks: +This package was inspired by and based on the Deducer +package (descriptive.table function). -\seealso{ - CreateContTable, print.ContTable, CreateCatTable, print.CatTable, - summary.CatTable +Developmental repository is on github. Your contributions +are appreciated. + +https://github.com/kaz-yos/tableone } \examples{ ## Load @@ -70,5 +57,11 @@ contTableOverall ## which will show more details. summary(contTableOverall) } -\keyword{ ~kwd1 } -\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line +\author{ +Kazuki YOSHIDA +} +\seealso{ +CreateContTable, print.ContTable, CreateCatTable, +print.CatTable, summary.CatTable +} + diff --git a/man/tableone_dummy-package.Rd b/man/tableone_dummy-package.Rd deleted file mode 100644 index fd410ae..0000000 --- a/man/tableone_dummy-package.Rd +++ /dev/null @@ -1,80 +0,0 @@ -\name{tableone-package} -\alias{tableone-package} -\alias{tableone} -\docType{package} -\title{ - Create the Table 1 to describe baseline characteristics -} -\description{ -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 functions in Deducer, Java-based GUI -package. This package does not require GUI or Java, and intended for CUI -users. -} -\details{ -\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 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. Continuous variables are handled by - CreateContTable, and categorical variables are handled by CreateCatTable. - -} -\author{ -Kazuki Yoshida - -Maintainer: Kazuki Yoshida - -} -\note{ - Special Thanks: - - This package was inspired by and based on the Deducer package. - - Developmental repository is on github. Your contributions are - appreciated. - - https://github.com/kaz-yos/tableone -} -\references{ - -} -\keyword{ package } -\seealso{ -} -\examples{ -## Load -library(tableone) - -## Load Mayo Clinic Primary Biliary Cirrhosis Data -library(survival) -data(pbc) -## Check variables -head(pbc) - -## Create an overall table for categorical variables -catVars <- c("status","ascites","hepato","spiders","edema","stage") -catTableOverall <- CreateCatTable(vars = catVars, data = pbc) - -## Simply typing the object name will invoke the print.CatTable method, -## which will show the sample size, frequencies and percentages. -## For 2-level variables, only the higher level is shown for simplicity. -catTableOverall - -## Create an overall table for continuous variables -contVars <- c("time","age","bili","chol","albumin","copper","alk.phos","ast", - "trig","platelet","protime") -contTableOverall <- CreateContTable(vars = contVars, data = pbc) - -## Simply typing the object name will invoke the print.ContTable method, -## which will show the sample size, means and standard deviations. -contTableOverall -}