barplotClinData {clinDataReview} | R Documentation |
Barplot visualization of clinical data.
Description
Barplot visualization of clinical data.
Usage
barplotClinData(
data,
xVar,
yVar,
xLab = getLabelVar(xVar, labelVars = labelVars),
xLabVar = NULL,
yLab = getLabelVar(yVar, labelVars = labelVars),
yLabVar = NULL,
colorVar = NULL,
colorLab = getLabelVar(colorVar, labelVars = labelVars),
colorPalette = NULL,
barmode = "group",
title = paste(c(paste(yLab, "vs", xLab), titleExtra), collapse = "<br>"),
titleExtra = NULL,
caption = NULL,
subtitle = NULL,
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)),
selectVars = NULL,
selectLab = getLabelVar(selectVars, labelVars = labelVars),
watermark = NULL,
verbose = FALSE
)
Arguments
data |
Data.frame with data. |
xVar |
String with column of |
yVar |
String with column of |
xLab |
String with label for |
xLabVar |
(optional) Character vector with column(s) of |
yLab |
String with label for |
yLabVar |
(optional) Character vector with column(s) of |
colorVar |
(optional) String with color variable. |
colorLab |
String with label for |
colorPalette |
(optional) Named character vector with color palette.
If not specified, the viridis color palette is used. |
barmode |
String with type of barplot, either:
'group' or 'stack' (see parameter in |
title |
String with title for the plot. |
titleExtra |
String with extra title for the plot (appended after |
caption |
String with caption. |
subtitle |
String with subtitle. |
labelVars |
Named character vector containing variable labels. |
width |
Numeric, width of the plot in pixels, 800 by default. |
height |
Numeric, height of the plot in pixels, 500 by default. |
hoverVars |
Character vector with variable(s) to be displayed in the hover, by default any position (and axis) and aesthetic variables displayed in the plot. |
hoverLab |
Named character vector with labels for |
textVar |
(optional) String with a text variable, that will be displayed outside of each bar. |
pathVar |
String with variable of <a href="./path-to-report">label</a> .
|
pathLab |
String with label for |
table |
Logical, if TRUE (FALSE by default)
returns also a |
tableVars |
Character vector with variables to be included in the table. |
tableLab |
Named character vector with labels
for each |
tableButton |
Logical, if TRUE (by default) the table is included within an HTML button. |
tablePars |
List with parameters passed to the
|
id |
String with general id for the plot:
If not specified, a random id, as 'plotClinData[X]' is used. |
selectVars |
(optional) Character vector with variable(s) from |
selectLab |
(Named) character vector with label for |
watermark |
(optional) String with path to a file containing a watermark. |
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:
if a
table
is requested: aclinDataReview
object, a.k.a a list with the 'plot' (plotly
object) and 'table' (datatable
object)otherwise: a
plotly
object
Author(s)
Laure Cougnaud
See Also
Other visualizations of summary statistics for clinical data:
boxplotClinData()
,
errorbarClinData()
,
plotCountClinData()
,
sunburstClinData()
,
treemapClinData()
Examples
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
if (requireNamespace("inTextSummaryTable", quietly = TRUE)) {
# total counts: Safety Analysis Set (patients with start date for the first treatment)
dataTotal <- subset(dataDM, RFSTDTC != "")
# compute adverse event table
tableAE <- inTextSummaryTable::computeSummaryStatisticsTable(
data = dataAE,
rowVar = c("AEBODSYS", "AEDECOD"),
rowOrder = "total",
dataTotal = dataTotal,
labelVars = labelVars,
stats = inTextSummaryTable::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
)
# add a selection box
if(interactive()){
barplotClinData(
data = dataPlot,
xVar = "AEDECOD",
yVar = "n", yLab = "Number of patients with adverse events",
labelVars = labelVars,
selectVars = "AEBODSYS"
)
}
## Not run:
# display percentage of events per severity
tableAEBySeverity <- inTextSummaryTable::computeSummaryStatisticsTable(
data = dataAE,
rowVar = c("AEDECOD", "AESEV"),
dataTotal = dataTotal,
labelVars = labelVars,
statsPerc = "statm",
stats = inTextSummaryTable::getStats("%m"),
dataTotalPerc = dataAE,
rowVarTotalPerc = "AEDECOD"
)
barplotClinData(
data = tableAEBySeverity,
xVar = "AEDECOD", xLab = "Adverse event term",
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",
# add subtitle
subtitle = "Group: severity"
)
## End(Not run)
}