barplotClinData: Barplot interactive plot.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/plots-barplotClinData.R

Description

Barplot interactive plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
barplotClinData(
  data,
  xVar,
  yVar,
  xLab = getLabelVar(xVar, labelVars = labelVars),
  yLab = getLabelVar(yVar, labelVars = labelVars),
  colorVar = NULL,
  colorLab = getLabelVar(colorVar, labelVars = labelVars),
  colorPalette = NULL,
  barmode = "group",
  titleExtra = NULL,
  title = paste(paste(yLab, "vs", xLab, titleExtra), collapse = "<br>"),
  labelVars = NULL,
  width = NULL,
  height = NULL,
  hoverVars,
  hoverLab,
  textVar = NULL,
  pathVar = NULL,
  pathLab = getLabelVar(pathVar, labelVars = labelVars),
  table = FALSE,
  tableVars,
  tableLab,
  tableButton = TRUE,
  tablePars = list(),
  id = paste0("plotClinData", sample.int(n = 1000, size = 1)),
  verbose = FALSE
)

Arguments

data

Data.frame with data.

xVar

String with column of data containing x-variable.

yVar

String with column of data containing y-variable.

xLab

String with label for xVar.

yLab

String with label for xVar.

colorVar

(optional) String with color variable.

colorLab

String with label for colorVar.

colorPalette

(optional) Named character vector with color palette. If not specified, the viridis color palette is used.
See clinColors.

barmode

String with type of barplot, either: 'group' or 'stack' (see parameter in layout).

titleExtra

String with extra title for the plot (appended after title).

title

String with title for the plot.

labelVars

Named character vector containing variable labels.

width

Numeric, width of the plot in pixels, 700 by default.

height

Numeric, height of the plot in pixels, 700 by default.

hoverVars

Character vector with variable(s) to be displayed in the hover, by default any position and aesthetic variables displayed in the plot.

hoverLab

Named character vector with labels for hoverVars.

textVar

(optional) String with a text variable, that will be displayed outside of each bar.

pathVar

String with variable of data containing hyperlinks with path to the subject-specific report, formatted as:

<a href="./path-to-report">label</a>

.
If multiple, they should be separated by: ', '.
The report(s) will be:

  • compressed to a zip file and downloaded if the user clicks on the 'p' (a.k.a 'profile') key when hovering on a point of the plot

  • included in a collapsible row, and clickable with hyperlinks in the table

pathLab

String with label for pathVar, included in the collapsible row in the table.

table

Logical, if TRUE (FALSE by default) returns also a datatable containing the plot data. (The plot and the table are not linked.)

tableVars

Character vector with variables to be included in the table.

tableLab

Named character vector with labels for each tableVars.

tableButton

Logical, if TRUE (by default) the table is included within an HTML button.

tablePars

List with parameters passed to the getClinDT function.

id

String with general id for the plot:

  • 'id' is used as group for the SharedData

  • 'button:[id]' is used as button ID if table is TRUE

If not specified, a random id, as 'plotClinData[X]' is used.

verbose

Logical, if TRUE (FALSE by default) progress messages are printed in the current console. For the visualizations, progress messages during download of subject-specific report are displayed in the browser console.

Value

Either:

Author(s)

Laure Cougnaud

See Also

Other visualizations of summary statistics for clinical data: boxplotClinData(), plotCountClinData(), sunburstClinData(), treemapClinData()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
library(clinUtils)

data(dataADaMCDISCP01)
labelVars <- attr(dataADaMCDISCP01, "labelVars")

dataAE <- dataADaMCDISCP01$ADAE
dataDM <- dataADaMCDISCP01$ADSL

## example of basic barplot:

# treemap takes as input table with counts
library(inTextSummaryTable)

# total counts: Safety Analysis Set (patients with start date for the first treatment)
dataTotal <- subset(dataDM, RFSTDTC != "")

# compute adverse event table
tableAE <- computeSummaryStatisticsTable(
	data = dataAE,
	rowVar = c("AEBODSYS", "AEDECOD"),
	dataTotal = dataTotal,
	labelVars = labelVars,
	stats = getStats("count")
)

dataPlot <- subset(tableAE, AEDECOD != "Total")

dataPlot$n <- as.numeric(dataPlot$n)

# create plot
barplotClinData(
	data = dataPlot,
	xVar = "AEDECOD", 
	yVar = "n", yLab = "Number of patients with adverse events",
	labelVars = labelVars
)
# add number on top of the bars
barplotClinData(
	data = dataPlot,
	xVar = "AEDECOD", 
	yVar = "n", yLab = "Number of patients with adverse events",
	textVar = "n",
	labelVars = labelVars
)

# display percentage of events per severity
tableAEBySeverity <- computeSummaryStatisticsTable(
	data = dataAE,
	rowVar = c("AEDECOD", "AESEV"),
	dataTotal = dataTotal,
	labelVars = labelVars,
	statsPerc = "statm",
	stats = getStats("%m"),
	dataTotalPerc = dataAE,
	rowVarTotalPerc = "AEDECOD"
)
barplotClinData(
	data = tableAEBySeverity,
	xVar = "AEDECOD", 
	yVar = "statPercm", yLab = "Percentage of adverse events",
	labelVars = labelVars,
	colorVar = "AESEV", barmode = "stack",
	hoverVar = c("AEDECOD", "AESEV", "statN", "statm", "statPercm"),
	hoverLab = c(
		labelVars["AEDECOD"],
		labelVars["AESEV"],
		statN = "Number of patients",
		statm = "Number of events",
		statPercm = "Percentage of events"
	),
	textVar = "%m",
)

clinDataReview documentation built on July 14, 2021, 5:08 p.m.