View source: R/horns-analyze.R
closure_horns_analyze | R Documentation |
Following up on closure_generate()
, you can call
closure_horns_analyze()
to compute the horns index for each individual
sample and compute summary statistics on the distribution of these indices.
See horns()
for the metric itself.
This adds more detail to the "horns"
and "horns_uniform"
columns in the
output of closure_generate()
, where "horns"
is the overall mean of the
per-sample indices found here.
closure_horns_histogram()
draws a quick barplot to reveal the
distribution of horns values. The scale is fixed between 0 and 1.
closure_horns_analyze(data)
closure_horns_histogram(
data,
bar_alpha = 0.8,
bar_color = "#5D3FD3",
bar_binwidth = 0.0025,
text_size = 12
)
data |
For |
bar_alpha |
Numeric (length 1). Opacity of the bars. Default is |
bar_color |
String (length 1). Color of the bars. Default is
|
bar_binwidth |
Width of the bins that divide up the x-axis, passed on to
|
text_size |
Numeric. Base font size in pt. Default is |
The "mad"
column overrides a default of stats::mad()
: adjusting
the result via multiplication by a constant (about 1.48). This assumes a
normal distribution, which generally does not seem to be the case with
horns index values. Here, the constant is set to 1.
closure_horns_analyze()
returns a named list of two tibbles (data
frames):
horns_metrics: Summary statistics of the distribution of horns index values:
mean
, uniform
: same as horns
and horns_uniform
from
closure_generate()
's output.
sd
: double. Standard deviation.
cv
: double. Coefficient of variation, i.e., sd / mean
.
mad
: double. Median absolute deviation; see stats::mad()
.
min
, median
, max
: double. Minimum, median, and maximum horns
index.
range
: double. Equal to max - min
.
horns_results:
id
: integer. Uniquely identifies each horns index, just like their
corresponding samples in closure_generate()
.
horns
: double. Horns index for each individual sample.
closure_horns_histogram()
returns a ggplot object.
data <- closure_generate(
mean = "2.9",
sd = "0.5",
n = 70,
scale_min = 1,
scale_max = 5
)
data_horns <- closure_horns_analyze(data)
data_horns
closure_horns_histogram(data_horns)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.