combplotp: Combination Plot

Description Usage Arguments Details Value Author(s) Examples

View source: R/combplotp.r

Description

Generates a plotly attribute plot given a series of possibly overlapping binary variables

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
combplotp(
  formula,
  data = NULL,
  subset,
  na.action = na.retain,
  vnames = c("labels", "names"),
  includenone = FALSE,
  showno = FALSE,
  maxcomb = NULL,
  minfreq = NULL,
  N = NULL,
  pos = function(x) 1 * (toupper(x) %in% c("true", "yes", "y", "positive", "+",
    "present", "1")),
  obsname = "subjects",
  ptsize = 35,
  width = NULL,
  height = NULL,
  ...
)

Arguments

formula

a formula containing all the variables to be cross-tabulated, on the formula's right hand side. There is no left hand side variable. If formula is omitted, then all variables from data are analyzed.

data

input data frame. If none is specified the data are assumed to come from the parent frame.

subset

an optional subsetting expression applied to data

na.action

see lm etc.

vnames

set to "names" to use variable names to label axes instead of variable labels. When using the default labels, any variable not having a label will have its name used instead.

includenone

set to TRUE to include the combination where all conditions are absent

showno

set to TRUE to show a light dot for conditions that are not part of the currently tabulated combination

maxcomb

maximum number of combinations to display

minfreq

if specified, any combination having a frequency less than this will be omitted from the display

N

set to an integer to override the global denominator, instead of using the number of rows in the data

pos

a function of vector returning a logical vector with TRUE values indicating positive

obsname

character string noun describing observations, default is "subjects"

ptsize

point size, defaults to 35

width

width of plotly plot

height

height of plotly plot

...

optional arguments to pass to table

Details

Similar to the UpSetR package, draws a special dot chart sometimes called an attribute plot that depicts all possible combination of the binary variables. By default a positive value, indicating that a certain condition pertains for a subject, is any of logical TRUE, numberic 1, "yes", "y", "positive", "+" or "present" value, and all others are considered negative. The user can override this determination by specifying her own pos function. Case is ignored in the variable values.

The plot uses solid dots arranged in a vertical line to indicate which combination of conditions is being considered. Frequencies of all possible combinations are shown above the dot chart. Marginal frequencies of positive values for the input variables are shown to the left of the dot chart. More information for all three of these component symbols is provided in hover text.

Variables are sorted in descending order of marginal frqeuencies and likewise for combinations of variables.

Value

plotly object

Author(s)

Frank Harrell

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
g <- function() sample(0:1, n, prob=c(1 - p, p), replace=TRUE)
set.seed(2); n <- 100; p <- 0.5
x1 <- g(); label(x1) <- 'A long label for x1 that describes it'
x2 <- g()
x3 <- g(); label(x3) <- 'This is<br>a label for x3'
x4 <- g()
combplotp(~ x1 + x2 + x3 + x4, showno=TRUE, includenone=TRUE)

n <- 1500; p <- 0.05
pain       <- g()
anxiety    <- g()
depression <- g()
soreness   <- g()
numbness   <- g()
tiredness  <- g()
sleepiness <- g()
combplotp(~ pain + anxiety + depression + soreness + numbness +
          tiredness + sleepiness, showno=TRUE)

Example output

Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package:HmiscThe following objects are masked frompackage:base:

    format.pval, units

Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
Warning messages:
1: `arrange_()` is deprecated as of dplyr 0.7.0.
Please use `arrange()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated. 
2: `group_by_()` is deprecated as of dplyr 0.7.0.
Please use `group_by()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated. 
3: Ignoring 4 observations 
Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
Warning messages:
1: Ignoring 3 observations 
2: Ignoring 4 observations 

Hmisc documentation built on Feb. 28, 2021, 9:05 a.m.