Browse Source

Add basic version of desc_tests

tags/0.3.0
Maxime Wack 2 years ago
parent
commit
b6f07decbc
2 changed files with 19 additions and 0 deletions
  1. +1
    -0
      NAMESPACE
  2. +18
    -0
      R/build.R

+ 1
- 0
NAMESPACE View File

@@ -16,6 +16,7 @@ export(IQR)
export(chisq.test)
export(datatable)
export(desc_table)
export(desc_tests)
export(desctable)
export(fisher.test)
export(group_by)


+ 18
- 0
R/build.R View File

@@ -217,4 +217,22 @@ desc_table.grouped_df <- function(data, stats = stats_auto, labels = NULL) {

desctable
}


#' Add tests to a desc_table
#'
#' @param data a desc_table
#' @param tests A list of statistical tests to use when calling desc_table with a grouped_df
#' @return A desc_table with tests
#' @export
desc_tests <- function(desctable, tests = tests_auto) {
if (which.desctable(desctable) != "grouped")
stop("Unexpected input. `desc_tests` is to be used on the result of `desc_table` on a grouped dataframe.\n
For example: iris %>% group_by(Species) %>% desc_table() %>% desc_tests")

fulldata <- tidyr::unnest(subset(desctable, select = -c(.stats, .vars)), data)

desctable$.tests <- list(testColumn(fulldata, tests, as.symbol(names(desctable)[1])))

desctable
}

Loading…
Cancel
Save