report_medianIQR: Report table of medians ± IQR (Interquartile Range)

View source: R/funciones.R

report_medianIQRR Documentation

Report table of medians ± IQR (Interquartile Range)

Description

report_medianIQR builds a table with the overall medians and (by default) quartiles 25 and 75 of one or more variables. A grouping variable can also be specified, in which case medians and quartiles are also calculated for each group and the p-value of a Kruskal-Wallis (more than 2 groups) or Wilcoxon test (two groups) is displayed to test the null hypothesis that the location parameters of the distribution of the variable are the same in each group.

Usage

report_medianIQR(
  data,
  summary_vars,
  groupVar = NULL,
  digits = 2,
  roundFrom = 30,
  probs = c(0.25, 0.75),
  pvdigits = 4,
  na.rm = TRUE
)

Arguments

data

data frame or tibble which contains the data.

summary_vars

Variable or variables whose median and quartiles is to be calculated.

groupVar

Grouping variable.

digits

Number of decimal digits for the results.

roundFrom

If median is greater than this value, median and IQR are rounded to zero decimals even if digits>0.

probs

Pair of quantiles to be computed around the median. Default are q25 and q75.

pvdigits

Number of decimal digits for the p-value of the test.

na.rm

Should NA values be removed (possible values are TRUE or FALSE)

Value

A table with the overall median and quartiles of the variables and, if a grouping variable is specified, the medians and quartiles by group and the p-value of the wilcoxon (two groups) or kruskal (more than two groups) test for comparing location parameters.

Examples

df <- data.frame(x=rnorm(100,10,3),y=rnorm(100,50,8), z=runif(100,20,30),g=sample(c("Yes","No"),100,replace=TRUE))
df %>%
report_medianIQR(c(x,y,z))  # Only overall medians and quartiles of variables x, y and z
df %>%
report_medianIQR(c(x,y,z), groupVar=g, digits=1)

angeloSdP/reportingTools documentation built on Dec. 25, 2024, 11:19 a.m.