display_table: Display a table

View source: R/display_table.R

display_tableR Documentation

Display a table

Description

Display count (frequency) or mean (standard deviation) table with the test of normality, etc.

Usage

display_table(
  data = NULL,
  variables = NULL,
  group = NULL,
  mean_or_median = "mean",
  addNA = TRUE,
  table_margin = 2,
  discrete_limit = 10,
  exclude_discrete = TRUE,
  save_to_file = NULL,
  normtest = NULL,
  fill_variable = FALSE
)

display_table_group(
  data = NULL,
  variables = NULL,
  group = NULL,
  super_group = NULL,
  group_combine = FALSE,
  mean_or_median = "mean",
  addNA = TRUE,
  table_margin = 2,
  discrete_limit = 10,
  exclude_discrete = TRUE,
  normtest = NULL,
  fill_variable = FALSE
)

Arguments

data

A data.frame

variables

Column indices or names of the variables in the dataset to display, the default columns are all the variables

group

Column indices or names of the first subgroup variables. Must provide.

mean_or_median

A character to specify mean or median to used for continuous variables, either "mean" or "median". The default is "mean"

addNA

Whether to include NA values in the table, see table for more details

table_margin

Index of generate margin for, see prop.table for more details

discrete_limit

A numeric defining the minimal of unique value to display the variable as count and frequency, the default is 10

exclude_discrete

Logical, whether to exclude discrete variables with more unique values specified by discrete_limit

save_to_file

A character, containing file name or path

normtest

A character indicating test of normality, the default method is shapiro.test when sample size no more than 5000, otherwise lillie.test Kolmogorov-Smirnov is used, see package nortest for more methods.Use 'shapiro.test', 'lillie.test', 'ad.test', etc to specify methods.

fill_variable

A logical, whether to fill the variable column in result, the default is FALSE

super_group

Column indices or names of the further subgroup variables.

group_combine

A logical, subgroup analysis for combination of group variables or for each group variables. The default is FALSE (subgroup analysis for each group variable)

Functions

  • display_table_group: Allow more subgroup analysis, see the package vignette for more details

Note

The return table is a data.frame.

- P.value1 is ANOVA P value for continuous variables and chi-square test P value for discrete variables

- P.value2 is Kruskal-Wallis test P value for continuous variables and fisher test P value for discrete variables if expected counts less than 5

- normality is normality test P value for each group

Examples

## Not run: 
data(diabetes)
head(diabetes)
library(dplyr);library(rlang)
result_1<-diabetes %>%
 group_by(sex) %>%
 do(display_table(data=.,variables=c("age","smoking"),group="CFHrs2230199")) %>%
 ungroup()
result_2<-display_table_group(data=diabetes,variables=c("age","smoking"),
group="CFHrs2230199",super_group = "sex")
identical(result,result1)
result_3<-display_table_group(data=diabetes,variables=c("age","education"),
group=c("smoking"),super_group = c("CFHrs2230199","sex"))
result_4<-display_table_group(data=diabetes,variables=c("age","education"),
group=c("smoking"),super_group = c("CFHrs2230199","sex"),group_combine=TRUE)

## End(Not run)

XikunHan/quickReg documentation built on March 21, 2022, 3:29 p.m.