Browse Source

Documentation

tags/0.1.0
Maxime Wack 7 years ago
parent
commit
92f9944657
20 changed files with 528 additions and 37 deletions
  1. +4
    -4
      DESCRIPTION
  2. +5
    -0
      NAMESPACE
  3. +15
    -0
      R/arg_functions.R
  4. +61
    -11
      R/build.R
  5. +32
    -10
      R/tests.R
  6. +14
    -0
      man/ANOVA.Rd
  7. +38
    -0
      man/chisq.test.Rd
  8. +104
    -0
      man/datatable.Rd
  9. +16
    -0
      man/datatable.desctable.Rd
  10. +38
    -8
      man/desctable.Rd
  11. +61
    -0
      man/fisher.test.Rd
  12. +16
    -0
      man/pander.desctable.Rd
  13. +19
    -0
      man/print.desctable.Rd
  14. +10
    -1
      man/stats_default.Rd
  15. +20
    -0
      man/subNames.Rd
  16. +23
    -0
      man/subTable.Rd
  17. +21
    -0
      man/testColumn.Rd
  18. +23
    -0
      man/testify.Rd
  19. +7
    -1
      man/tests_auto.Rd
  20. +1
    -2
      man/varColumn.Rd

+ 4
- 4
DESCRIPTION View File

@@ -3,8 +3,8 @@ Title: Produce Descriptive and Comparative Tables Easily
Version: 0.0.0.9000
Authors@R: person("Maxime", "Wack", email = "maximewack@free.fr", role = c("aut", "cre"))
Description: This package provides functions to easily create descriptive and
comparative tables. It makes use and integrates directly with the dplyr family
of packages and pipes. Tables are produced as data frames/lists of data frames
comparative tables. It makes use and integrates directly with the tidyverse family
of packages, and pipes. Tables are produced as data frames/lists of data frames
for easy manipulation after creation, and ready to be saved as csv, piped to
datatable or pander to integrate into reports.
Depends:
@@ -16,8 +16,8 @@ Imports:
dplyr,
purrr,
stringr,
tibble
Suggests:
tibble,
DT,
pander
Suggests:
RoxygenNote: 6.0.1

+ 5
- 0
NAMESPACE View File

@@ -2,15 +2,20 @@

S3method(print,desctable)
export("%>%")
export(ANOVA)
export(IQR)
export(Q1)
export(Q3)
export(Range)
export(chisq.test)
export(datatable)
export(desctable)
export(desctable.default)
export(desctable.grouped_df)
export(fisher.test)
export(group_by)
export(list_normal)
export(pander.desctable)
export(parse_formula)
export(percent)
export(petrify)


+ 15
- 0
R/arg_functions.R View File

@@ -1,5 +1,15 @@
#' Functions to create a list of statistics to use in desctable
#'
#' These functions take a dataframe as argument and return a list of statistcs in the form accepted by desctable.
#'
#' Already defined are
#' - stats_default with length, mean/%, sd, med and IQR
#' - stats_normal with length, mean/% and sd
#' - stats_nonnormal with length, median/% and IQR
#' - 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.
#'
#' @param data The dataframe to apply the statistic to
#' @return A list of statistics to use, potentially assessed from the dataframe
#' @export
@@ -70,8 +80,13 @@ stats_auto <- function(data)

#' Functions to choose a statistical test
#'
#' These functions take a variable and a grouping variable as arguments, and return a statistcal test to use.
#'
#' Currently, only 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.
#'
#' @param var The variable to test
#' @param grp The variable for the groups
#' @return A statistical test function
#' @export
tests_auto <- function(var, grp)
{


+ 61
- 11
R/build.R View File

@@ -29,8 +29,7 @@ statTable <- function(data, stats)
#' Generate the variable column to display as row names
#'
#' Generates the variable column.
#' Replaces the variable names by their label if given in the named character vector labels
#' Inserts levels for factors
#' Replaces the variable names by their label if given in the named character vector labels, and inserts levels for factors.
#'
#' 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.
@@ -69,20 +68,45 @@ varColumn <- function(data, labels = NULL)
#' 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.
#' labels must be given in the form c(unquoted_variable_name = "label")
#'
#' If data is a grouped dataframe (using group_by), subtables are created and statistic tests are perfored over each sub-group.
#' The stats can be a function which takes a dataframe and returns a list of statistical functions to use.
#' stats can also be a named list of statistical functions, or formulas. 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. If an element of the list is a formula, it can be used to conditionally use stats depending on the variable. The general form is `condition ~ T | F`, and can be nested, such as `is.factor ~ percent | (is.normal ~ mean | median)`, for example.
#'
#' For a simple descriptive table (without groups), the resulting dataframe is directly pipe-able to pander or DT, or can be exported like any dataframe to csv, etc.
#' For a grouped table, the output is list of dataframes that can be manipulated, prior to passing to the petrify() function which will make it pipe-able to pander or DT.
#' labels must be given in the form c(unquoted_variable_name = "label")
#' The tests can be a function which takes a variable and a grouping variable, and returns an appropriate statistical test to use in that case.
#' tests can also be a named list of statistical test functions, associating the name of a variable in the data, and a test to use specifically for that variable. You don't have to specify tests for all the variables: a default test for all other variables can be defined with the name .default, and an automatic test can be defined with the name .auto.
#'
#' If data is a grouped dataframe (using group_by), subtables are created and statistic tests are performed over each sub-group.
#'
#' The output is a desctable object, which is a list of named dataframes that can be further manipulated. Methods for printing, using in pander and DT::datatable are present. Printing reduces the object to a dataframe.
#'
#' @param data The dataframe to analyse
#' @param data The dataframe to analyze
#' @param stats A list of named statistics to apply to each element of the dataframe, or a function returning a list of named statistics
#' @param tests A list of statistcal tests to use when calling desctable with a grouped_df
#' @param tests A list of statistical tests to use when calling desctable with a grouped_df
#' @param labels A named character vector of labels to use instead of variable names
#' @return A table of statistics for all variables
#' @seealso \code{\link{petrify}}
#' @return A desctable object, which prints to a table of statistics for all variables
#' @seealso \code{\link{stats_auto}}
#' @seealso \code{\link{tests_auto}}
#' @seealso \code{\link{print.desctable}}
#' @seealso \code{\link{pander.desctable}}
#' @seealso \code{\link{datatable.desctable}}
#' @export
#' @examples
#' iris %>% desctable
#'
#' mtcars %>% desctable(labels = c(hp = "Horse Power"))
#'
#' iris %>%
#' group_by(Species) %>%
#' desctable
#'
#' mtcars %>%
#' group_by(vs, cyl) %>%
#' desctable
#'
#' iris %>%
#' group_by(Petal.Length > 5) %>%
#' desctable(tests = list(.auto = tests_auto, Species = chisq.test))
desctable <- function(data, stats = stats_auto, tests = tests_auto, labels = NULL)
{
# Replace every logical vector with a factor and nice labels
@@ -116,6 +140,14 @@ desctable.grouped_df <- function(data, stats, tests, labels)
`class<-`("desctable")
}

#' Create the subtables names
#'
#' Create the subtables names, as
#' factor: level (n=sub-group length)
#'
#' @param grp Grouping factor
#' @param df Dataframe containing the grouping factor
#' @return A character vector with the names for the subtables
subNames <- function(grp, df)
{
paste0(as.character(grp),
@@ -126,6 +158,12 @@ subNames <- function(grp, df)
")")
}

#' Create the pvalues column
#'
#' @param df Dataframe to use for the tests
#' @param tests Test function or list of functions
#' @param grp Grouping factor
#' @return A numeric vector of pvalues
testColumn <- function(df, tests, grp)
{
group <- eval(grp, df)
@@ -160,6 +198,13 @@ testColumn <- function(df, tests, grp)
purrr::map2(ftests, testify, group) %>% purrr::flatten_dbl()
}

#' Create a subtable in a grouped desctable
#'
#' @param df Dataframe to use
#' @param stats Stats list/function to use
#' @param tests Tests list/function to use
#' @param grps List of symbols for grouping factors
#' @return A nested list of statTables and testColumns
subTable <- function(df, stats, tests, grps)
{
# Final group, make tests
@@ -183,7 +228,7 @@ subTable <- function(df, stats, tests, grps)
{
group <- eval(grps[[1]], df)

# Recursively go through the grouping levels and build the subtables
# Go through the next grouping levels and build the subtables
df %>%
dplyr::select(- eval(grps[[1]])) %>%
by(group, subTable, stats, tests, grps[-1]) %>%
@@ -215,6 +260,11 @@ petrify <- function(data, digits = 2, ...)
data %>% lapply(prettyNum, digits = digits, ...) %>% lapply(base::gsub, pattern = "^NA$", replacement = "") %>% data.frame(check.names = F)
}

#' Print method for desctable
#'
#' @param x A desctable
#' @param ... Additional print parameters
#' @return A flat dataframe
#' @export
print.desctable <- function(x, ...)
{


+ 32
- 10
R/tests.R View File

@@ -1,3 +1,12 @@
#' Transform any test function into a valid test function for the table
#'
#' 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
#' @param x A vector
#' @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
testify <- function(x, f, group)
{
p <- tryCatch(f(x ~ group)$p.value[1],
@@ -8,30 +17,43 @@ testify <- function(x, f, group)
p
}

fisher.test.default <- stats::fisher.test

fisher.test <- function(...)
#' Fisher test
#'
#' @inheritParams stats::fisher.test
#' @seealso stats::fisher.test
#' @export
fisher.test <- function(x, y = NULL, workspace = 200000, hybrid = FALSE, control = list(), or = 1, alternative = "two.sided", conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE, B = 2000)
{
UseMethod("fisher.test")
}

fisher.test.formula <- function(formula, ...)
fisher.test.default <- stats::fisher.test

fisher.test.formula <- function(x, ...)
{
fisher.test.default(x = eval(formula[[2]], envir = parent.frame()), y = eval(formula[[3]], envir = parent.frame()), ...)
fisher.test.default(x = eval(x[[2]], envir = parent.frame()), y = eval(x[[3]], envir = parent.frame()), ...)
}

chisq.test.default <- stats::chisq.test

chisq.test <- function(...)
#' Chi-square test
#'
#' @inheritParams stats::chisq.test
#' @export
chisq.test <- function(x, y = NULL, correct = TRUE, p = rep(1/length(x), length(x)), rescale.p = FALSE, simulate.p.value = FALSE, B = 2000)
{
UseMethod("chisq.test")
}

chisq.test.formula <- function(formula, ...)
chisq.test.default <- stats::chisq.test

chisq.test.formula <- function(x, y = NULL, correct = TRUE, p = rep(1/length(x), length(x)), rescale.p = FALSE, simulate.p.value = FALSE, B = 2000, ...)
{
chisq.test.default(x = eval(formula[[2]], envir = parent.frame()), y = eval(formula[[3]], envir = parent.frame()), ...)
chisq.test.default(x = eval(x[[2]], envir = parent.frame()), y = eval(x[[3]], envir = parent.frame()), ...)
}

#' Wrapper for summary(aov)
#'
#' @param formula An anova formula (variable ~ grouping variable)
#' @export
ANOVA <- function(formula)
{
summary(stats::aov(formula))[[1]] %>%


+ 14
- 0
man/ANOVA.Rd View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tests.R
\name{ANOVA}
\alias{ANOVA}
\title{Wrapper for summary(aov)}
\usage{
ANOVA(formula)
}
\arguments{
\item{formula}{An anova formula (variable ~ grouping variable)}
}
\description{
Wrapper for summary(aov)
}

+ 38
- 0
man/chisq.test.Rd View File

@@ -0,0 +1,38 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tests.R
\name{chisq.test}
\alias{chisq.test}
\title{Chi-square test}
\usage{
chisq.test(x, y = NULL, correct = TRUE, p = rep(1/length(x), length(x)),
rescale.p = FALSE, simulate.p.value = FALSE, B = 2000)
}
\arguments{
\item{x}{a numeric vector or matrix. \code{x} and \code{y} can also
both be factors.}

\item{y}{a numeric vector; ignored if \code{x} is a matrix. If
\code{x} is a factor, \code{y} should be a factor of the same length.}

\item{correct}{a logical indicating whether to apply continuity
correction when computing the test statistic for 2 by 2 tables: one
half is subtracted from all \eqn{|O - E|} differences; however, the
correction will not be bigger than the differences themselves. No correction
is done if \code{simulate.p.value = TRUE}.}

\item{p}{a vector of probabilities of the same length of \code{x}.
An error is given if any entry of \code{p} is negative.}

\item{rescale.p}{a logical scalar; if TRUE then \code{p} is rescaled
(if necessary) to sum to 1. If \code{rescale.p} is FALSE, and
\code{p} does not sum to 1, an error is given.}

\item{simulate.p.value}{a logical indicating whether to compute
p-values by Monte Carlo simulation.}

\item{B}{an integer specifying the number of replicates used in the
Monte Carlo test.}
}
\description{
Chi-square test
}

+ 104
- 0
man/datatable.Rd View File

@@ -0,0 +1,104 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{datatable}
\alias{datatable}
\title{Datatable}
\usage{
datatable(data, options = list(), class = "display",
callback = JS("return table;"), rownames, colnames, container,
caption = NULL, filter = c("none", "bottom", "top"), escape = TRUE,
style = "default", width = NULL, height = NULL, elementId = NULL,
fillContainer = getOption("DT.fillContainer", NULL),
autoHideNavigation = getOption("DT.autoHideNavigation", NULL),
selection = c("multiple", "single", "none"), extensions = list(),
plugins = NULL)
}
\arguments{
\item{data}{a data object (either a matrix or a data frame)}

\item{options}{a list of initialization options (see
\url{http://datatables.net/reference/option/}); the character options
wrapped in \code{\link[htmlwidgets]{JS}()} will be treated as literal
JavaScript code instead of normal character strings; you can also set
options globally via \code{\link{options}(DT.options = list(...))}, and
global options will be merged into this \code{options} argument if set}

\item{class}{the CSS class(es) of the table; see
\url{http://datatables.net/manual/styling/classes}}

\item{callback}{the body of a JavaScript callback function with the argument
\code{table} to be applied to the DataTables instance (i.e. \code{table})}

\item{rownames}{\code{TRUE} (show row names) or \code{FALSE} (hide row names)
or a character vector of row names; by default, the row names are displayed
in the first column of the table if exist (not \code{NULL})}

\item{colnames}{if missing, the column names of the data; otherwise it can be
an unnamed character vector of names you want to show in the table header
instead of the default data column names; alternatively, you can provide a
\emph{named} numeric or character vector of the form \code{'newName1' = i1,
'newName2' = i2} or \code{c('newName1' = 'oldName1', 'newName2' =
'oldName2', ...)}, where \code{newName} is the new name you want to show in
the table, and \code{i} or \code{oldName} is the index of the current
column name}

\item{container}{a sketch of the HTML table to be filled with data cells; by
default, it is generated from \code{htmltools::tags$table()} with a table
header consisting of the column names of the data}

\item{caption}{the table caption; a character vector or a tag object
generated from \code{htmltools::tags$caption()}}

\item{filter}{whether/where to use column filters; \code{none}: no filters;
\code{bottom/top}: put column filters at the bottom/top of the table; range
sliders are used to filter numeric/date/time columns, select lists are used
for factor columns, and text input boxes are used for character columns; if
you want more control over the styles of filters, you can provide a list to
this argument of the form \code{list(position = 'top', clear = TRUE, plain
= FALSE)}, where \code{clear} indicates whether you want the clear buttons
in the input boxes, and \code{plain} means if you want to use Bootstrap
form styles or plain text input styles for the text input boxes}

\item{escape}{whether to escape HTML entities in the table: \code{TRUE} means
to escape the whole table, and \code{FALSE} means not to escape it;
alternatively, you can specify numeric column indices or column names to
indicate which columns to escape, e.g. \code{1:5} (the first 5 columns),
\code{c(1, 3, 4)}, or \code{c(-1, -3)} (all columns except the first and
third), or \code{c('Species', 'Sepal.Length')}}

\item{style}{the style name (\url{http://datatables.net/manual/styling/});
currently only \code{'default'} and \code{'bootstrap'} are supported}

\item{width}{Width/Height in pixels (optional, defaults to automatic
sizing)}

\item{height}{Width/Height in pixels (optional, defaults to automatic
sizing)}

\item{elementId}{An id for the widget (a random string by default).}

\item{fillContainer}{\code{TRUE} to configure the table to automatically fill
it's containing element. If the table can't fit fully into it's container
then vertical and/or horizontal scrolling of the table cells will occur.}

\item{autoHideNavigation}{\code{TRUE} to automatically hide navigational UI
when the number of total records is less than the page size.}

\item{selection}{the row/column selection mode (single or multiple selection
or disable selection) when a table widget is rendered in a Shiny app;
alternatively, you can use a list of the form \code{list(mode = 'multiple',
selected = c(1, 3, 8), target = 'row')} to pre-select rows; the element
\code{target} in the list can be \code{'column'} to enable column
selection, or \code{'row+column'} to make it possible to select both rows
and columns (click on the footer to select columns), or \code{'cell'} to
select cells}

\item{extensions}{a character vector of the names of the DataTables
extensions (\url{http://datatables.net/extensions/index})}

\item{plugins}{a character vector of the names of DataTables plug-ins
(\url{http://rstudio.github.io/DT/plugins.html})}
}
\description{
Datatable
}

+ 16
- 0
man/datatable.desctable.Rd View File

@@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{datatable.desctable}
\alias{datatable.desctable}
\title{datatable method for desctable}
\usage{
\method{datatable}{desctable}(data = NULL, ...)
}
\arguments{
\item{data}{A desctable}

\item{...}{Additional datatable parameters}
}
\description{
datatable method for desctable
}

+ 38
- 8
man/desctable.Rd View File

@@ -13,16 +13,16 @@ desctable.default(data, stats, tests, labels)
desctable.grouped_df(data, stats, tests, labels)
}
\arguments{
\item{data}{The dataframe to analyse}
\item{data}{The dataframe to analyze}

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

\item{tests}{A list of statistcal tests to use when calling desctable with a grouped_df}
\item{tests}{A list of statistical tests to use when calling desctable with a grouped_df}

\item{labels}{A named character vector of labels to use instead of variable names}
}
\value{
A table of statistics for all variables
A desctable object, which prints to a table of statistics for all variables
}
\description{
Generate a statistics table with variable names/labels and levels
@@ -31,13 +31,43 @@ Generate a statistics table with variable names/labels and levels
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.
labels must be given in the form c(unquoted_variable_name = "label")

If data is a grouped dataframe (using group_by), subtables are created and statistic tests are perfored over each sub-group.
The stats can be a function which takes a dataframe and returns a list of statistical functions to use.
stats can also be a named list of statistical functions, or formulas. 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. If an element of the list is a formula, it can be used to conditionally use stats depending on the variable. The general form is `condition ~ T | F`, and can be nested, such as `is.factor ~ percent | (is.normal ~ mean | median)`, for example.

For a simple descriptive table (without groups), the resulting dataframe is directly pipe-able to pander or DT, or can be exported like any dataframe to csv, etc.
For a grouped table, the output is list of dataframes that can be manipulated, prior to passing to the petrify() function which will make it pipe-able to pander or DT.
labels must be given in the form c(unquoted_variable_name = "label")
The tests can be a function which takes a variable and a grouping variable, and returns an appropriate statistical test to use in that case.
tests can also be a named list of statistical test functions, associating the name of a variable in the data, and a test to use specifically for that variable. You don't have to specify tests for all the variables: a default test for all other variables can be defined with the name .default, and an automatic test can be defined with the name .auto.

If data is a grouped dataframe (using group_by), subtables are created and statistic tests are performed over each sub-group.

The output is a desctable object, which is a list of named dataframes that can be further manipulated. Methods for printing, using in pander and DT::datatable are present. Printing reduces the object to a dataframe.
}
\examples{
iris \%>\% desctable

mtcars \%>\% desctable(labels = c(hp = "Horse Power"))

iris \%>\%
group_by(Species) \%>\%
desctable

mtcars \%>\%
group_by(vs, cyl) \%>\%
desctable

iris \%>\%
group_by(Petal.Length > 5) \%>\%
desctable(tests = list(.auto = tests_auto, Species = chisq.test))
}
\seealso{
\code{\link{petrify}}
\code{\link{stats_auto}}

\code{\link{tests_auto}}

\code{\link{print.desctable}}

\code{\link{pander.desctable}}

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

+ 61
- 0
man/fisher.test.Rd View File

@@ -0,0 +1,61 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tests.R
\name{fisher.test}
\alias{fisher.test}
\title{Fisher test}
\usage{
fisher.test(x, y = NULL, workspace = 2e+05, hybrid = FALSE,
control = list(), or = 1, alternative = "two.sided", conf.int = TRUE,
conf.level = 0.95, simulate.p.value = FALSE, B = 2000)
}
\arguments{
\item{x}{either a two-dimensional contingency table in matrix form,
or a factor object.}

\item{y}{a factor object; ignored if \code{x} is a matrix.}

\item{workspace}{an integer specifying the size of the workspace
used in the network algorithm. In units of 4 bytes. Only used for
non-simulated p-values larger than \eqn{2 \times 2}{2 by 2} tables.}

\item{hybrid}{a logical. Only used for larger than \eqn{2 \times 2}{2 by 2}
tables, in which cases it indicates whether the exact probabilities
(default) or a hybrid approximation thereof should be computed.
See \sQuote{Details}.}

\item{control}{a list with named components for low level algorithm
control. At present the only one used is \code{"mult"}, a positive
integer \eqn{\ge 2} with default 30 used only for larger than
\eqn{2 \times 2}{2 by 2} tables. This says how many times as much
space should be allocated to paths as to keys: see file
\file{fexact.c} in the sources of this package.}

\item{or}{the hypothesized odds ratio. Only used in the
\eqn{2 \times 2}{2 by 2} case.}

\item{alternative}{indicates the alternative hypothesis and must be
one of \code{"two.sided"}, \code{"greater"} or \code{"less"}.
You can specify just the initial letter. Only used in the
\eqn{2 \times 2}{2 by 2} case.}

\item{conf.int}{logical indicating if a confidence interval for the
odds ratio in a \eqn{2 \times 2}{2 by 2} table should be
computed (and returned).}

\item{conf.level}{confidence level for the returned confidence
interval. Only used in the \eqn{2 \times 2}{2 by 2} case and if
\code{conf.int = TRUE}.}

\item{simulate.p.value}{a logical indicating whether to compute
p-values by Monte Carlo simulation, in larger than \eqn{2 \times
2}{2 by 2} tables.}

\item{B}{an integer specifying the number of replicates used in the
Monte Carlo test.}
}
\description{
Fisher test
}
\seealso{
stats::fisher.test
}

+ 16
- 0
man/pander.desctable.Rd View File

@@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{pander.desctable}
\alias{pander.desctable}
\title{Pander method for desctable}
\usage{
pander.desctable(x = NULL, ...)
}
\arguments{
\item{x}{A desctable}

\item{...}{Additional pander parameters}
}
\description{
Pander method for desctable
}

+ 19
- 0
man/print.desctable.Rd View File

@@ -0,0 +1,19 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{print.desctable}
\alias{print.desctable}
\title{Print method for desctable}
\usage{
\method{print}{desctable}(x, ...)
}
\arguments{
\item{x}{A desctable}

\item{...}{Additional print parameters}
}
\value{
A flat dataframe
}
\description{
Print method for desctable
}

+ 10
- 1
man/stats_default.Rd View File

@@ -22,5 +22,14 @@ stats_auto(data)
A list of statistics to use, potentially assessed from the dataframe
}
\description{
Functions to create a list of statistics to use in desctable
These functions take a dataframe as argument and return a list of statistcs in the form accepted by desctable.
}
\details{
Already defined are
- stats_default with length, mean/%, sd, med and IQR
- stats_normal with length, mean/% and sd
- stats_nonnormal with length, median/% and IQR
- 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.
}

+ 20
- 0
man/subNames.Rd View File

@@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{subNames}
\alias{subNames}
\title{Create the subtables names}
\usage{
subNames(grp, df)
}
\arguments{
\item{grp}{Grouping factor}

\item{df}{Dataframe containing the grouping factor}
}
\value{
A character vector with the names for the subtables
}
\description{
Create the subtables names, as
factor: level (n=sub-group length)
}

+ 23
- 0
man/subTable.Rd View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{subTable}
\alias{subTable}
\title{Create a subtable in a grouped desctable}
\usage{
subTable(df, stats, tests, grps)
}
\arguments{
\item{df}{Dataframe to use}

\item{stats}{Stats list/function to use}

\item{tests}{Tests list/function to use}

\item{grps}{List of symbols for grouping factors}
}
\value{
A nested list of statTables and testColumns
}
\description{
Create a subtable in a grouped desctable
}

+ 21
- 0
man/testColumn.Rd View File

@@ -0,0 +1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build.R
\name{testColumn}
\alias{testColumn}
\title{Create the pvalues column}
\usage{
testColumn(df, tests, grp)
}
\arguments{
\item{df}{Dataframe to use for the tests}

\item{tests}{Test function or list of functions}

\item{grp}{Grouping factor}
}
\value{
A numeric vector of pvalues
}
\description{
Create the pvalues column
}

+ 23
- 0
man/testify.Rd View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tests.R
\name{testify}
\alias{testify}
\title{Transform any test function into a valid test function for the table}
\usage{
testify(x, f, group)
}
\arguments{
\item{x}{A vector}

\item{f}{The function to try to apply, or a formula combining two functions}

\item{group}{Grouping factor}
}
\value{
The results for the function applied on the vector, compatible with the format of the result table
}
\description{
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
}

+ 7
- 1
man/tests_auto.Rd View File

@@ -11,6 +11,12 @@ tests_auto(var, grp)

\item{grp}{The variable for the groups}
}
\value{
A statistical test function
}
\description{
Functions to choose a statistical test
These functions take a variable and a grouping variable as arguments, and return a statistcal test to use.
}
\details{
Currently, only 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.
}

+ 1
- 2
man/varColumn.Rd View File

@@ -16,8 +16,7 @@ A dataframe with one variable named "Variables", a character vector of variable
}
\description{
Generates the variable column.
Replaces the variable names by their label if given in the named character vector labels
Inserts levels for factors
Replaces the variable names by their label if given in the named character vector labels, and inserts levels for factors.
}
\details{
labels is an option named character vector used to make the table prettier.


Loading…
Cancel
Save