Learn R Programming

descsuppRplots (version 1.0)

plotDescTbl: Variable Visualizations for Descriptive Tables

Description

Using as underlying functions the plot functions from ggstatsplot this package visualizes the variables in a descriptive table generated via buildDescrTbl.

Usage

plotDescTbl(
  dtab,
  plotfuns = NULL,
  verbose = 0,
  pairwise.display = "none",
  pval.display = FALSE,
  ...
)

Value

tibble with column p containing the plots.

Arguments

dtab

data.frame with attributes descrtbl_full, data, and groupby as generated by buildDescrTbl

plotfuns

named list of tibbles. names must be in dtab$parameter. entries must be of the form tibble(plotfun = "betweenstats", args = list(list(messages = FALSE, type = "nonparametric"))). For missing entries plotDescTbl tries to guess a suitable plot function. Defaults to NULL meaning that the plot functions for all parameters are guessed.

verbose

logical or integer. Level of verbosity. If TRUE or > 0, print some messages. Defaults to 0.

pairwise.display

Decides if and which pairwise comparisons are shown in the plots. Available options are: - `"none"` - `"significant"` (abbreviation accepted: `"s"`) - `"non-significant"` (abbreviation accepted: `"ns"`) - `"all"` Defaults to "none".

pval.display

logical. If TRUE p-values are shown in the plots. If dtab contains adjusted p-values, these are shown in the plots. Defaults to FALSE.

...

additional parameters will be passed to the plotting functions.

Author

Dr. Andreas Leha

Examples

Run this code
ttt <- data.frame(data="training set",
                  age=runif(100, 0, 100),
                  sex=as.factor(sample(c("m","f"), 100, replace=TRUE, prob=c(0.3, 0.7))),
                  score=factor(sample(1:5, 100, replace=TRUE),
                    ordered=TRUE,
                    levels=1:5))
ttt2 <- data.frame(data="test set",
                   age=runif(100, 0, 100),
                   sex=as.factor(sample(c("m","f"), 100, replace=TRUE, prob=c(0.5,0.5))),
                   score=factor(sample(1:5, 100, replace=TRUE),
                     ordered=TRUE,
                     levels=1:5))

## ungrouped table and plots
dtab <- buildDescrTbl(dplyr::mutate(rbind(ttt, ttt2), data = as.factor(data)),
                      includeNAs=TRUE,
                      dopvals = TRUE)

plotDescTbl(dtab)

## grouped table and plots
dtab <- buildDescrTbl(dplyr::mutate(rbind(ttt, ttt2), data = as.factor(data)),
                      groupby="data",
                      includeNAs=TRUE,
                      dopvals = TRUE)

plotDescTbl(dtab)

Run the code above in your browser using DataLab