Browse Source

Update documentation

- update documentation for new API
- add keywords, seealso and family desc_table
- update roxygen
tags/0.3.0
Maxime Wack 2 years ago
parent
commit
5dfc92bdac
37 changed files with 425 additions and 59 deletions
  1. +1
    -0
      NAMESPACE
  2. +59
    -17
      R/build.R
  3. +15
    -0
      R/deprecated.R
  4. +18
    -4
      R/output.R
  5. +1
    -0
      R/stats.R
  6. +1
    -0
      R/tests.R
  7. +2
    -0
      R/utils.R
  8. +2
    -1
      man/as.data.frame.desctable.Rd
  9. +2
    -1
      man/datatable.Rd
  10. +45
    -0
      man/desc_output.Rd
  11. +98
    -0
      man/desc_table.Rd
  12. +57
    -0
      man/desc_tests.Rd
  13. +2
    -1
      man/desctable.Rd
  14. +3
    -1
      man/flatten_desctable.Rd
  15. +3
    -1
      man/head_dataframe.Rd
  16. +3
    -1
      man/head_datatable.Rd
  17. +3
    -1
      man/head_pander.Rd
  18. +3
    -1
      man/header.Rd
  19. +3
    -1
      man/headerList.Rd
  20. +1
    -0
      man/insert.Rd
  21. +2
    -1
      man/pander.desctable.Rd
  22. +30
    -0
      man/parse_formula.Rd
  23. +2
    -1
      man/print.desctable.Rd
  24. +2
    -2
      man/reexports.Rd
  25. +3
    -1
      man/set_desctable_class.Rd
  26. +1
    -0
      man/statColumn.Rd
  27. +1
    -0
      man/statTable.Rd
  28. +1
    -0
      man/statify.Rd
  29. +20
    -0
      man/stats_auto.Rd
  30. +6
    -19
      man/stats_default.Rd
  31. +3
    -1
      man/subNames.Rd
  32. +3
    -1
      man/subTable.Rd
  33. +1
    -0
      man/testColumn.Rd
  34. +1
    -0
      man/testify.Rd
  35. +4
    -3
      man/tests_auto.Rd
  36. +1
    -0
      man/varColumn.Rd
  37. +22
    -0
      man/which.desctable.Rd

+ 1
- 0
NAMESPACE View File

@@ -15,6 +15,7 @@ export(ANOVA)
export(IQR)
export(chisq.test)
export(datatable)
export(desc_output)
export(desc_table)
export(desc_tests)
export(desctable)


+ 59
- 17
R/build.R View File

@@ -8,6 +8,7 @@
#'
#' @param stat The statistic to use
#' @param data The dataframe to apply the statistic to
#' @keywords internal
#' @return A vector for one statistic column
statColumn <- function(stat, data) {
# Apply one statified stat function to every variable in the data
@@ -33,6 +34,7 @@ For example, `is.normal ~ mean | median` becomes `~ if (is.normal(.)) mean(.) el
#'
#' @param data The dataframe to apply the statistic to
#' @param stats A list of named statistics to use
#' @keywords internal
#' @return A dataframe of all statistics for all variables
statTable <- function(data, stats) {
# If stats is a function, apply it to the data to obtain a list of stat functions
@@ -60,6 +62,7 @@ statTable <- function(data, stats) {
#'
#' @param data The dataframe to get the names from
#' @param labels The optional named character vector containing the keypairs var = "Label"
#' @keywords internal
#' @return A dataframe with one variable named "Variables", a character vector of variable names/labels and levels
varColumn <- function(data, labels = NULL) {
# Every variable name that exists in the labels is to be replaced with its corresponding label
@@ -101,6 +104,7 @@ varColumn <- function(data, labels = NULL) {
#' @param df Dataframe to use for the tests
#' @param tests Test function or list of functions
#' @param grp Grouping factor
#' @keywords internal
#' @return A numeric vector of pvalues
testColumn <- function(df, tests, grp) {
group <- eval(grp, df)
@@ -135,36 +139,45 @@ testColumn <- function(df, tests, grp) {

#' Generate a statistics table
#'
#' Generate a statistics table with the chosen statistical functions, and tests if given a \code{"grouped"} dataframe.
#' Generate a statistics table with the chosen statistical functions, nested if called with a grouped dataframe.
#'
#' @section Stats:
#' The stats can be a function which takes a dataframe and returns a list of statistical functions to use.
#' The statistical functions to use in the table are passed as additional arguments.
#' If the argument is named (eg. \code{N = length}) the name will be used as the column title instead of the function
#' name (here, \strong{N} instead of \strong{length}).
#'
#' stats can also be a named list of statistical functions, or purrr::map like formulas.
#' Any R function can be a statistical function, as long as it returns only one value when applied to a vector, or as
#' many values as there are levels in a factor, plus one.
#'
#' Users can also use \code{purrr::map}-like formulas as quick anonymous functions (eg. \code{Q1 = ~ quantile(., .25)} to get the first quantile in a
#' column named \strong{Q1})
#'
#' If no statistical function is given to \code{desc_table}, the \code{.auto} argument is used to provide a function
#' that automatically determines the most appropriate statistical functions to use based on the contents of the table.
#'
#' The names will be used as column names in the resulting table. If an element of the list is a function, it will be used as-is for the stats.
#' @section Labels:
#' labels is an option named character vector used to make the table prettier.
#' \code{.labels} is a named character vector to provide "pretty" labels to variables.
#'
#' If given, the variable names for which there is a label will be replaced by their corresponding label.
#'
#' Not all variables need to have a label, and labels for non-existing variables are ignored.
#'
#' labels must be given in the form c(unquoted_variable_name = "label")
#' labels must be given in the form \code{c(unquoted_variable_name = "label")}
#'
#' @section Output:
#' The output is either a dataframe in the case of a simple descriptive table,
#' or nested dataframes in the case of a comparative table.
#'
#' @param data The dataframe to analyze
#' @param ... A list of named statistics to apply to each element of the dataframe, or a function returning a list of named statistics
#' @param .auto A function to automatically determine appropriate statistics
#' @param .labels A named character vector of variable labels
#' @param ... list of named statistics to apply to each element of the dataframe, or a function returning a list of named statistics
#' @return A desctable object, which prints to a table of statistics for all variables
#' @return A simple or grouped descriptive table
#' @seealso \code{\link{stats_auto}}
#' @seealso \code{\link{desc_tests}}
#' @seealso \code{\link{desc_output}}
#' @seealso \code{\link{IQR}}
#' @seealso \code{\link{percent}}
#' @export
#' @family desc_table core functions
#' @examples
#' iris %>%
#' desc_table()
@@ -172,15 +185,19 @@ testColumn <- function(df, tests, grp) {
#' # Does the same as stats_auto here
#' iris %>%
#' desc_table("N" = length,
#' "Mean" = ~ if (is.normal(.)) mean(.),
#' "sd" = ~ if (is.normal(.)) sd(.),
#' "Med" = stats::median,
#' "IQR" = ~ if(!is.factor(.)) IQR(.))
#' "Min" = min,
#' "Q1" = ~quantile(., .25),
#' "Med" = median,
#' "Mean" = mean,
#' "Q3" = ~quantile(., .75),
#' "Max" = max,
#' "sd" = sd,
#' "IQR" = IQR)
#'
#' # With grouping on a factor
#' iris %>%
#' group_by(Species) %>%
#' desc_table(.auto = stats_default)
#' desc_table(.auto = stats_auto)
desc_table <- function(data, ..., .auto, .labels) {
UseMethod("desc_table", data)
}
@@ -246,12 +263,37 @@ desc_table.grouped_df <- function(data, ..., .auto = stats_auto, .labels = NULL)

#' Add tests to a desc_table
#'
#' @param desctable a desc_table
#' @param ... A list of statistical tests to use when calling desc_table with a grouped_df
#' Add test statistics to a grouped desc_table, with the tests specified as \code{variable = test}.
#'
#' @section Tests:
#' The statistical test functions to use in the table are passed as additional named arguments. Tests must be preceded
#' by a formula tilde (\code{~}).
#' \code{name = ~test} will apply test \code{test} to variable \code{name}.
#'
#' Any R test function can be used, as long as it returns an object containing a \code{p.value} element, which is the
#' case for most tests returning an object of class \code{htest}.
#'
#' Users can also use \code{purrr::map}-like formulas as quick anonymous functions (eg. \code{~ t.test(., var.equal = T)} to
#' compute a t test without the Welch correction.
#'
#' @param desctable A desc_table
#' @param ... A list of statistical tests associated to variable names
#' @param .auto A function to automatically determine the appropriate tests
#' @param .default A default fallback test
#' @seealso \code{\link{tests_auto}}
#' @seealso \code{\link{no.test}}
#' @seealso \code{\link{ANOVA}}
#' @return A desc_table with tests
#' @export
#' @family desc_table core functions
#' @examples
#' iris %>%
#' group_by(Species) %>%
#' desc_table() %>%
#' desc_tests(Sepal.Length = ~kruskal.test,
#' Sepal.Width = ~oneway.test,
#' Petal.Length = ~oneway.test(., var.equal = T),
#' Petal.Length = ~oneway.test(., var.equal = F))
desc_tests <- function(desctable, .auto = tests_auto, .default = NULL, ...) {
if (which.desctable(desctable) != "grouped")
stop("Unexpected input. `desc_tests` must be used on the output of `desc_table` on a grouped dataframe.\n


+ 15
- 0
R/deprecated.R View File

@@ -46,6 +46,7 @@ pander::pander
#' @seealso \code{\link{pander.desctable}}
#' @seealso \code{\link{datatable.desctable}}
#' @export
#' @keywords deprecated
#' @examples
#' iris %>%
#' desctable()
@@ -117,6 +118,7 @@ desctable.grouped_df <- function(data, stats = stats_auto, tests = tests_auto, l
#' @param grp Grouping factor
#' @param df Dataframe containing the grouping factor
#' @return A character vector with the names for the subtables
#' @keywords deprecated internal
subNames <- function(grp, df) {
paste0(as.character(grp),
": ",
@@ -134,6 +136,7 @@ subNames <- function(grp, df) {
#' @param tests Tests list/function to use
#' @param grps List of symbols for grouping factors
#' @return A nested list of statTables and testColumns
#' @keywords deprecated internal
subTable <- function(df, stats, tests, grps) {
# Final group, compute tests
if (length(grps) == 1) {
@@ -167,6 +170,7 @@ subTable <- function(df, stats, tests, grps) {
#' @param ... Additional print parameters
#' @return A flat dataframe
#' @export
#' @keywords deprecated
print.desctable <- function(x, ...) {
print(as.data.frame(x))
}
@@ -178,6 +182,7 @@ print.desctable <- function(x, ...) {
#' @param ... Additional as.data.frame parameters
#' @return A flat dataframe
#' @export
#' @keywords deprecated
as.data.frame.desctable <- function(x, ...) {
# Discard "markdown" formatting of variable names
x$Variables$Variables <- gsub("\\*\\*(.*?)\\*\\*", "\\1", x$Variables$Variables)
@@ -204,6 +209,7 @@ as.data.frame.desctable <- function(x, ...) {
#' @inheritParams pander::pandoc.table
#' @seealso \code{\link{pandoc.table}}
#' @export
#' @keywords deprecated
pander.desctable <- function(x = NULL,
digits = 2,
justify = "left",
@@ -272,6 +278,7 @@ pander.desctable <- function(x = NULL,
#' ###
#' @inheritParams DT::datatable
#' @export
#' @keywords deprecated
datatable <- function(data, ...) {
UseMethod("datatable", data)
}
@@ -370,6 +377,7 @@ datatable.desctable <- function(data,
#'
#' @param x Object to set the "desctable" class to
#' @return The object with the class "desctable"
#' @keywords deprecated internal
set_desctable_class <- function(x) {
class(x) <- "desctable"

@@ -392,6 +400,7 @@ set_desctable_class <- function(x) {
#' @param x The variable to test it on
#' @param f A formula to parse
#' @return A function to use as a stat/test
#' @keywords deprecated internal
parse_formula <- function(x, f) {
parse_f <- function(x) {
if (length(x) == 1) as.character(x)
@@ -420,6 +429,7 @@ parse_formula <- function(x, f) {
#'
#' @param head A headerList object
#' @return A names vector
#' @keywords deprecated internal
head_pander <- function(head) {
if (is.integer(head[[1]])) {
head %>%
@@ -443,6 +453,7 @@ head_pander <- function(head) {
#'
#' @param head A headerList object
#' @return An htmltools$tags object containing the header
#' @keywords deprecated internal
head_datatable <- function(head) {
TRs <- list()

@@ -461,6 +472,7 @@ head_datatable <- function(head) {
#'
#' @param head A headerList object
#' @return A names vector
#' @keywords deprecated internal
head_dataframe <- function(head) {
if (is.integer(head[[1]])) {
head %>%
@@ -488,6 +500,7 @@ head_dataframe <- function(head) {
#' @param desctable A desctable object
#' @param output An output format for the header
#' @return A header object in the output format
#' @keywords deprecated internal
header <- function(desctable, output = c("pander", "datatable", "dataframe")) {
desctable[-1] %>%
flatten_desctable() %>%
@@ -529,6 +542,7 @@ header <- function(desctable, output = c("pander", "datatable", "dataframe")) {
#'
#' @param desctable a desctable
#' @return a nested list of headers with colspans
#' @keywords deprecated internal
headerList <- function(desctable) {
if (is.data.frame(desctable)) length(desctable)
else {
@@ -546,6 +560,7 @@ headerList <- function(desctable) {
#'
#' @param desctable A desctable object
#' @return A flat dataframe
#' @keywords deprecated internal
flatten_desctable <- function(desctable) {
if (is.data.frame(desctable)) desctable
else {


+ 18
- 4
R/output.R View File

@@ -1,12 +1,26 @@
##' Output a desctable to the desired target
##' Output a desctable to the desired target format
##'
##' Output a simple or grouped desctable to a different formats.
##' Currently available formats are\itemize{
##' \item data.frame ("df")
##' \item pander ("pander")
##' \item datatable ("DT")
##' }
##'
##' All numerical values will be rounded to the digits argument.
##' If statistical tests are presents, p values below 1E-digits will be replaced with "≤ 1E-digits"
##' (eg. "≤ 0.01" for values below 0.01 when digits = 2)
##'
##' @title desc_output
##' @param desctable The desctable to output
##' @param target The desired target. One of ~df~, ~pander~, or ~DT~.
##' @param digits The number of digits to display. The p values will be simplified under 10^-digits
##' @param ... Other arguments to pass to data.frame, pander::pander, or DT::datatable
##' @param target The desired target. One of "df", "pander", or "DT".
##' @param digits The number of digits to display. The p values will be simplified under 1E-digits
##' @param ... Other arguments to pass to \code{data.frame}, \code{pander::pander}, or \code{DT::datatable}
##' @return The output object (or corresponding side effect)
##' @export
##' @seealso \code{\link[DT]{datatable}}
##' @seealso \code{\link[pander]{pander}}
##' @family desc_table core functions
desc_output <- function(desctable, target = c("df", "pander", "DT"), digits = 2, ...) {
switch(which.desctable(desctable),
simple = switch(target,


+ 1
- 0
R/stats.R View File

@@ -13,6 +13,7 @@
#' @param x A vector
#' @export
#' @return The results for the function applied on the vector, compatible with the format of the result table
#' @keywords internal
statify <- function(x, f) {
# Discard NA values
x <- stats::na.omit(x)


+ 1
- 0
R/tests.R View File

@@ -7,6 +7,7 @@
#' @param f The function to try to apply, or a formula combining two functions
#' @param group Grouping factor
#' @return The results for the function applied on the vector, compatible with the format of the result table
#' @keywords internal
testify <- function(x, f, group) {
# Extract the name of the function
f %>%


+ 2
- 0
R/utils.R View File

@@ -7,6 +7,7 @@
#' @param y A vector or list of vectors to insert into x
#' @param position The position / vector of positions to insert vector(s) y in vector x
#' @return The combined vector
#' @keywords internal
insert <- function(x, y, position) {
# y is supposed to be a list of vectors. If it is a single vector, make it a simple list containing that vector
if (!is.list(y)) y <- list(y)
@@ -40,6 +41,7 @@ insert <- function(x, y, position) {
#'
#' @param desctable A potential desctable to check
#' @return The type of desctable or FALSE
#' @keywords internal
which.desctable <- function(desctable)
{
attributes <- list()


+ 2
- 1
man/as.data.frame.desctable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/output.R
% Please edit documentation in R/deprecated.R
\name{as.data.frame.desctable}
\alias{as.data.frame.desctable}
\title{As.data.frame method for desctable}
@@ -17,3 +17,4 @@ A flat dataframe
\description{
As.data.frame method for desctable
}
\keyword{deprecated}

+ 2
- 1
man/datatable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/output.R
% Please edit documentation in R/deprecated.R
\name{datatable}
\alias{datatable}
\alias{datatable.default}
@@ -191,3 +191,4 @@ datatable(data.frame(x = Sys.time()))
\references{
See \url{https://rstudio.github.io/DT/} for the full documentation.
}
\keyword{deprecated}

+ 45
- 0
man/desc_output.Rd View File

@@ -0,0 +1,45 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/output.R
\name{desc_output}
\alias{desc_output}
\title{desc_output}
\usage{
desc_output(desctable, target = c("df", "pander", "DT"), digits = 2, ...)
}
\arguments{
\item{desctable}{The desctable to output}

\item{target}{The desired target. One of "df", "pander", or "DT".}

\item{digits}{The number of digits to display. The p values will be simplified under 1E-digits}

\item{...}{Other arguments to pass to \code{data.frame}, \code{pander::pander}, or \code{DT::datatable}}
}
\value{
The output object (or corresponding side effect)
}
\description{
Output a desctable to the desired target format
}
\details{
Output a simple or grouped desctable to a different formats.
Currently available formats are\itemize{
\item data.frame ("df")
\item pander ("pander")
\item datatable ("DT")
}

All numerical values will be rounded to the digits argument.
If statistical tests are presents, p values below 1E-digits will be replaced with "≤ 1E-digits"
(eg. "≤ 0.01" for values below 0.01 when digits = 2)
}
\seealso{
\code{\link[DT]{datatable}}

\code{\link[pander]{pander}}

Other desc_table core functions:
\code{\link{desc_table}()},
\code{\link{desc_tests}()}
}
\concept{desc_table core functions}

+ 98
- 0
man/desc_table.Rd View File

@@ -0,0 +1,98 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{desc_table}
\alias{desc_table}
\alias{desc_table.default}
\alias{desc_table.data.frame}
\alias{desc_table.grouped_df}
\title{Generate a statistics table}
\usage{
desc_table(data, ..., .auto, .labels)

\method{desc_table}{default}(data, ..., .auto, .labels)

\method{desc_table}{data.frame}(data, ..., .labels = NULL, .auto = stats_auto)

\method{desc_table}{grouped_df}(data, ..., .auto = stats_auto, .labels = NULL)
}
\arguments{
\item{data}{The dataframe to analyze}

\item{...}{A list of named statistics to apply to each element of the dataframe, or a function returning a list of named statistics}

\item{.auto}{A function to automatically determine appropriate statistics}

\item{.labels}{A named character vector of variable labels}
}
\value{
A simple or grouped descriptive table
}
\description{
Generate a statistics table with the chosen statistical functions, nested if called with a grouped dataframe.
}
\section{Stats}{

The statistical functions to use in the table are passed as additional arguments.
If the argument is named (eg. \code{N = length}) the name will be used as the column title instead of the function
name (here, \strong{N} instead of \strong{length}).

Any R function can be a statistical function, as long as it returns only one value when applied to a vector, or as
many values as there are levels in a factor, plus one.

Users can also use \code{purrr::map}-like formulas as quick anonymous functions (eg. \code{Q1 = ~ quantile(., .25)} to get the first quantile in a
column named \strong{Q1})

If no statistical function is given to \code{desc_table}, the \code{.auto} argument is used to provide a function
that automatically determines the most appropriate statistical functions to use based on the contents of the table.
}

\section{Labels}{

\code{.labels} is a named character vector to provide "pretty" labels to variables.

If given, the variable names for which there is a label will be replaced by their corresponding label.

Not all variables need to have a label, and labels for non-existing variables are ignored.

labels must be given in the form \code{c(unquoted_variable_name = "label")}
}

\section{Output}{

The output is either a dataframe in the case of a simple descriptive table,
or nested dataframes in the case of a comparative table.
}

\examples{
iris \%>\%
desc_table()

# Does the same as stats_auto here
iris \%>\%
desc_table("N" = length,
"Min" = min,
"Q1" = ~quantile(., .25),
"Med" = median,
"Mean" = mean,
"Q3" = ~quantile(., .75),
"Max" = max,
"sd" = sd,
"IQR" = IQR)

# With grouping on a factor
iris \%>\%
group_by(Species) \%>\%
desc_table(.auto = stats_auto)
}
\seealso{
\code{\link{stats_auto}}

\code{\link{IQR}}

\code{\link{percent}}

Other desc_table core functions:
\code{\link{desc_output}()},
\code{\link{desc_tests}()}
}
\concept{desc_table core functions}

+ 57
- 0
man/desc_tests.Rd View File

@@ -0,0 +1,57 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{desc_tests}
\alias{desc_tests}
\title{Add tests to a desc_table}
\usage{
desc_tests(desctable, .auto = tests_auto, .default = NULL, ...)
}
\arguments{
\item{desctable}{A desc_table}

\item{.auto}{A function to automatically determine the appropriate tests}

\item{.default}{A default fallback test}

\item{...}{A list of statistical tests associated to variable names}
}
\value{
A desc_table with tests
}
\description{
Add test statistics to a grouped desc_table, with the tests specified as \code{variable = test}.
}
\section{Tests}{

The statistical test functions to use in the table are passed as additional named arguments. Tests must be preceded
by a formula tilde (\code{~}).
\code{name = ~test} will apply test \code{test} to variable \code{name}.

Any R test function can be used, as long as it returns an object containing a \code{p.value} element, which is the
case for most tests returning an object of class \code{htest}.

Users can also use \code{purrr::map}-like formulas as quick anonymous functions (eg. \code{~ t.test(., var.equal = T)} to
compute a t test without the Welch correction.
}

\examples{
iris \%>\%
group_by(Species) \%>\%
desc_table() \%>\%
desc_tests(Sepal.Length = ~kruskal.test,
Sepal.Width = ~oneway.test,
Petal.Length = ~oneway.test(., var.equal = T),
Petal.Length = ~oneway.test(., var.equal = F))
}
\seealso{
\code{\link{tests_auto}}

\code{\link{no.test}}

\code{\link{ANOVA}}

Other desc_table core functions:
\code{\link{desc_output}()},
\code{\link{desc_table}()}
}
\concept{desc_table core functions}

+ 2
- 1
man/desctable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
% Please edit documentation in R/deprecated.R
\name{desctable}
\alias{desctable}
\alias{desctable.default}
@@ -108,3 +108,4 @@ iris \%>\%

\code{\link{datatable.desctable}}
}
\keyword{deprecated}

+ 3
- 1
man/flatten_desctable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{flatten_desctable}
\alias{flatten_desctable}
\title{Flatten a desctable to a dataframe recursively}
@@ -15,3 +15,5 @@ A flat dataframe
\description{
Flatten a desctable to a dataframe recursively
}
\keyword{deprecated}
\keyword{internal}

+ 3
- 1
man/head_dataframe.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{head_dataframe}
\alias{head_dataframe}
\title{Build the header for dataframe}
@@ -15,3 +15,5 @@ A names vector
\description{
Build the header for dataframe
}
\keyword{deprecated}
\keyword{internal}

+ 3
- 1
man/head_datatable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{head_datatable}
\alias{head_datatable}
\title{Build the header for datatable}
@@ -15,3 +15,5 @@ An htmltools$tags object containing the header
\description{
Build the header for datatable
}
\keyword{deprecated}
\keyword{internal}

+ 3
- 1
man/head_pander.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{head_pander}
\alias{head_pander}
\title{Build the header for pander}
@@ -15,3 +15,5 @@ A names vector
\description{
Build the header for pander
}
\keyword{deprecated}
\keyword{internal}

+ 3
- 1
man/header.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{header}
\alias{header}
\title{Build header}
@@ -18,3 +18,5 @@ A header object in the output format
Take a desctable object and create a suitable header for the mentionned output.
Output can be one of "pander", "datatable", or "dataframe".
}
\keyword{deprecated}
\keyword{internal}

+ 3
- 1
man/headerList.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{headerList}
\alias{headerList}
\title{build a header list object}
@@ -15,3 +15,5 @@ a nested list of headers with colspans
\description{
build a header list object
}
\keyword{deprecated}
\keyword{internal}

+ 1
- 0
man/insert.Rd View File

@@ -20,3 +20,4 @@ The combined vector
The vectors in the y list will be inserted
at positions respectively *after* the x[position] element of x
}
\keyword{internal}

+ 2
- 1
man/pander.desctable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/output.R
% Please edit documentation in R/deprecated.R
\name{pander.desctable}
\alias{pander.desctable}
\title{Pander method for desctable}
@@ -41,3 +41,4 @@ Uses \code{pandoc.table}, with some default parameters (\code{digits = 2}, \code
\seealso{
\code{\link{pandoc.table}}
}
\keyword{deprecated}

+ 30
- 0
man/parse_formula.Rd View File

@@ -0,0 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deprecated.R
\name{parse_formula}
\alias{parse_formula}
\title{Parse a formula}
\usage{
parse_formula(x, f)
}
\arguments{
\item{x}{The variable to test it on}

\item{f}{A formula to parse}
}
\value{
A function to use as a stat/test
}
\description{
Parse a formula defining the conditions to pick a stat/test
}
\details{
Parse a formula defining the conditions to pick a stat/test
and return the function to use.
The formula is to be given in the form of
conditional ~ T | F
and conditions can be nested such as
conditional1 ~ (conditional2 ~ T | F) | F
The FALSE option can be omitted, and the TRUE can be replaced with NA
}
\keyword{deprecated}
\keyword{internal}

+ 2
- 1
man/print.desctable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/output.R
% Please edit documentation in R/deprecated.R
\name{print.desctable}
\alias{print.desctable}
\title{Print method for desctable}
@@ -17,3 +17,4 @@ A flat dataframe
\description{
Print method for desctable
}
\keyword{deprecated}

+ 2
- 2
man/reexports.Rd View File

@@ -1,11 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/imports.R
% Please edit documentation in R/deprecated.R, R/imports.R
\docType{import}
\name{reexports}
\alias{reexports}
\alias{pander}
\alias{\%>\%}
\alias{group_by}
\alias{pander}
\title{Objects exported from other packages}
\keyword{internal}
\description{


+ 3
- 1
man/set_desctable_class.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
% Please edit documentation in R/deprecated.R
\name{set_desctable_class}
\alias{set_desctable_class}
\title{Set the "desctable" class to the passed object}
@@ -15,3 +15,5 @@ The object with the class "desctable"
\description{
Set the "desctable" class to the passed object
}
\keyword{deprecated}
\keyword{internal}

+ 1
- 0
man/statColumn.Rd View File

@@ -22,3 +22,4 @@ to produce a single statistics column.
The result is either a numeric vector, or a character vector if
the content of the column is not made entirely of numbers.
}
\keyword{internal}

+ 1
- 0
man/statTable.Rd View File

@@ -19,3 +19,4 @@ If stats is a list of functions or purrr::map like formulas, use them.
If it is a single function, use it with the entire data as
its argument to produce a list of statistical functions to use.
}
\keyword{internal}

+ 1
- 0
man/statify.Rd View File

@@ -26,3 +26,4 @@ Applying the function on a factor should return nlevels + 1 value, or one value

See \code{parse_formula} for the usage for formulaes.
}
\keyword{internal}

+ 20
- 0
man/stats_auto.Rd View File

@@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats.R
\name{stats_auto}
\alias{stats_auto}
\title{Function to create a list of statistics to use in desctable}
\usage{
stats_auto(data)
}
\arguments{
\item{data}{The dataframe to apply the statistic to}
}
\value{
A list of statistics to use, assessed from the content of the dataframe
}
\description{
This function takes a dataframe as argument and returns a list of statistcs in the form accepted by desctable.
}
\details{
You can define your own automatic function, as long as it takes a dataframe as argument and returns a list of functions, or formulas defining conditions to use a stat function.
}

+ 6
- 19
man/stats_default.Rd View File

@@ -1,37 +1,24 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats.R
% Please edit documentation in R/deprecated.R
\name{stats_default}
\alias{stats_default}
\alias{stats_normal}
\alias{stats_nonnormal}
\alias{stats_auto}
\title{Functions to create a list of statistics to use in desctable}
\title{Define a list of default statistics}
\usage{
stats_default(data)

stats_normal(data)

stats_nonnormal(data)

stats_auto(data)
}
\arguments{
\item{data}{The dataframe to apply the statistic to}
\item{data}{A dataframe}
}
\value{
A list of statistics to use, potentially assessed from the dataframe
A list of statistical functions
}
\description{
These functions take a dataframe as argument and return a list of statistcs in the form accepted by desctable.
}
\details{
Already defined are
\enumerate{
\item stats_default with length, \%, mean, sd, med and IQR
\item stats_normal with length, \%, mean and sd
\item stats_nonnormal with length, %, median and IQR
\item stats_auto, which picks stats depending of the data
}

You can define your own automatic functions, as long as they take a dataframe as argument and return a list of functions or formulas defining conditions to use a stat function.
Define a list of default statistics
}
\keyword{deprecated}

+ 3
- 1
man/subNames.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
% Please edit documentation in R/deprecated.R
\name{subNames}
\alias{subNames}
\title{Create the subtables names}
@@ -18,3 +18,5 @@ A character vector with the names for the subtables
Create the subtables names, as
factor: level (n=sub-group length)
}
\keyword{deprecated}
\keyword{internal}

+ 3
- 1
man/subTable.Rd View File

@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
% Please edit documentation in R/deprecated.R
\name{subTable}
\alias{subTable}
\title{Create a subtable in a grouped desctable}
@@ -21,3 +21,5 @@ A nested list of statTables and testColumns
\description{
Create a subtable in a grouped desctable
}
\keyword{deprecated}
\keyword{internal}

+ 1
- 0
man/testColumn.Rd View File

@@ -19,3 +19,4 @@ A numeric vector of pvalues
\description{
Create the pvalues column
}
\keyword{internal}

+ 1
- 0
man/testify.Rd View File

@@ -21,3 +21,4 @@ Transform a function into a valid test function for the table
Applying the function on a numerical vector should return one value
Applying the function on a factor should return nlevels + 1 value, or one value per factor level
}
\keyword{internal}

+ 4
- 3
man/tests_auto.Rd View File

@@ -2,7 +2,7 @@
% Please edit documentation in R/tests.R
\name{tests_auto}
\alias{tests_auto}
\title{Functions to choose a statistical test}
\title{Function to choose a statistical test}
\usage{
tests_auto(var, grp)
}
@@ -15,8 +15,9 @@ tests_auto(var, grp)
A statistical test function
}
\description{
These functions take a variable and a grouping variable as arguments, and return a statistcal test to use, expressed as a single-term formula.
This function takes a variable and a grouping variable as arguments, and returns a statistcal test to use, expressed as a single-term formula.
}
\details{
Currently, only \code{tests_auto} is defined, and picks between t test, wilcoxon, anova, kruskal-wallis and fisher depending on the number of groups, the type of the variable, the normality and homoskedasticity of the distributions.
This function uses appropriate non-parametric tests depending on the number of levels (wilcoxon.test for two levels
and kruskal.test for more), and fisher.test with fallback on chisq.test on error for factors.
}

+ 1
- 0
man/varColumn.Rd View File

@@ -23,3 +23,4 @@ labels is an option named character vector used to make the table prettier.
If given, the variable names for which there is a label will be replaced by their corresponding label.
Not all variables need to have a label, and labels for non-existing variables are ignored.
}
\keyword{internal}

+ 22
- 0
man/which.desctable.Rd View File

@@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{which.desctable}
\alias{which.desctable}
\title{Is the object possibly a desctable?}
\usage{
which.desctable(desctable)
}
\arguments{
\item{desctable}{A potential desctable to check}
}
\value{
The type of desctable or FALSE
}
\description{
Check if the object is produced by desc_table.
Return a string:
- simple
- grouped
or FALSE if not a desctable
}
\keyword{internal}

Loading…
Cancel
Save