| plot_bar | R Documentation |
plot_bar draws bar charts that
represent the proportions of frequencies in the current
population popu as relatives sizes of
rectangular areas.
plot_bar(
prev = num$prev,
sens = num$sens,
mirt = NA,
spec = num$spec,
fart = NA,
N = num$N,
by = "all",
dir = 1,
scale = "f",
round = TRUE,
sample = FALSE,
f_lbl = "num",
f_lwd = 1,
lty = 0,
lbl_txt = txt,
main = txt$scen_lbl,
sub = "type",
title_lbl = NULL,
col_pal = pal,
mar_notes = FALSE,
...
)
prev |
The condition's prevalence |
sens |
The decision's sensitivity |
mirt |
The decision's miss rate |
spec |
The decision's specificity value |
fart |
The decision's false alarm rate |
N |
The number of individuals in the population.
(This value is not represented in the plot,
but used when new frequency information |
by |
A character code specifying the perspective (or the dimension by which the population is split into 2 subsets) with the following options:
|
dir |
Number of directions in which bars are plotted. Options:
|
scale |
Scale the heights of bars either
by current frequencies ( |
round |
Boolean option specifying whether computed frequencies
are to be rounded to integers.
Default: |
sample |
Boolean value that determines whether frequency values
are sampled from |
f_lbl |
Type of frequency labels, as character code with the following options:
|
f_lwd |
Line width of frequency box (border).
Values of |
lty |
Line type of frequency box (border).
Values of |
lbl_txt |
Current text information (for labels, titles, etc.).
Default: |
main |
Text label for main plot title.
Default: |
sub |
Text label for plot subtitle (on 2nd line).
Default: |
title_lbl |
Deprecated text label for current plot title.
Replaced by |
col_pal |
Current color palette.
Default: |
mar_notes |
Boolean option for showing margin notes.
Default: |
... |
Other (graphical) parameters
(e.g., |
If a sufficient and valid set of 3 essential probabilities
(prev, and
sens or its complement mirt, and
spec or its complement fart)
is provided, new frequency information freq
and a new population table popu
are computed from scratch. Otherwise, the existing
population popu is shown.
By default, plot_bar uses current frequencies
(i.e., rounded or not rounded, depending on the value of round)
as bar heights, rather than using exact probabilities to
scale bar heights (i.e., default scaling is scale = "f").
Using the option scale = "p" scales bar heights
by probabilities (e.g., showing bars for non-natural frequencies
even when frequencies are rounded).
When round = FALSE, bar heights for scale = "f"
and for scale = "p" are identical.
The distinction between scale = "f" and
scale = "p" matters mostly for
small populations sizes N
(e.g., when N < 100).
For rounded and small frequency values (e.g., freq < 10)
switching from scale = "f" to scale = "p"
yields different plots.
plot_bar contrasts compound frequencies along 1 dimension (height).
See plot_mosaic for 2-dimensional visualizations (as areas)
and various box) options in
plot_tree and plot_fnet
for related functions.
comp_popu computes the current population;
popu contains the current population;
comp_freq computes current frequency information;
freq contains current frequency information;
num for basic numeric parameters;
txt for current text settings;
pal for current color settings
Other visualization functions:
plot.riskyr(),
plot_area(),
plot_crisk(),
plot_curve(),
plot_fnet(),
plot_icons(),
plot_mosaic(),
plot_plane(),
plot_prism(),
plot_tab(),
plot_tree()
# Basics:
# (1) Using global prob and freq values:
plot_bar()
# (2) Providing values:
plot_bar(prev = .33, sens = .75, spec = .66, main = "Test 1")
plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, main = "Test 2") # by "all" (default)
# (3) Rounding and sampling:
plot_bar(N = 100, prev = 1/3, sens = 2/3, spec = 6/7, area = "hr", round = FALSE)
plot_bar(N = 100, prev = 1/3, sens = 2/3, spec = 6/7, area = "hr", sample = TRUE, scale = "freq")
# Perspectives (by):
# plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, by = "cd",
# main = "Test 3a") # by condition
plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, by = "cd", dir = 2,
main = "Test 3b", f_lbl = "num") # bi-directional
# plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, by = "dc",
# main = "Test 4a") # by decision
plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, by = "dc", dir = 2,
main = "Test 4b", f_lbl = "num") # bi-directional
# plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, by = "ac",
# main = "Test 5a") # by accuracy
plot_bar(N = 1000, prev = .33, sens = .75, spec = .60, by = "ac", dir = 2,
main = "Test 5b", f_lbl = "num") # bi-directional
# Customize colors and text:
plot_bar(dir = 1, f_lbl = "num", col_pal = pal_org)
# plot_bar(dir = 2, f_lbl = "nam", col_pal = pal_bw)
# Frequency labels (f_lbl):
# plot_bar(f_lbl = "def") # default labels: name = num
plot_bar(f_lbl = "nam") # name only
plot_bar(f_lbl = "num") # numeric value only
# plot_bar(f_lbl = "abb") # abbreviated name
# plot_bar(f_lbl = NA) # no labels (NA/NULL/"no")
# Scaling and rounding effects:
plot_bar(N = 3, prev = .1, sens = .7, spec = .6, dir = 2,
scale = "f", round = TRUE,
main = "Rounding (1)") # => Scale by freq and round freq.
plot_bar(N = 3, prev = .1, sens = .7, spec = .6, dir = 2,
scale = "p", round = TRUE,
main = "Rounding (2)") # => Scale by prob and round freq.
plot_bar(N = 3, prev = .1, sens = .7, spec = .6, dir = 2,
scale = "f", round = FALSE,
main = "Rounding (3)") # => Scale by freq and do NOT round freq.
plot_bar(N = 3, prev = .1, sens = .7, spec = .6, dir = 2,
scale = "p", round = FALSE,
main = "Rounding (4)") # => Scale by prob and do NOT round freq.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.