fig_density {whomds} | R Documentation |
Plot a density of a score
Description
Plot a density of a score
Usage
fig_density(
df,
score,
var_color = NULL,
var_facet = NULL,
cutoffs = NULL,
x_lab = "Score",
pal = "Paired",
adjust = 2,
size = 1.5
)
Arguments
df |
a data frame where each row is an individual, containing at least a score column (between 0 and 100) |
score |
a string (length 1) of the column name for the score variable to print the distribution of |
var_color |
a string (length 1) of the column name for the variable to set color of density lines by. Default is NULL. |
var_facet |
a string (length 1) of the column name for the variable to create a |
cutoffs |
a numeric vector of the cut-offs for the score categorization. Default is NULL. |
x_lab |
a string (length 1) of x-axis label. Default is "Score". |
pal |
a string specifying either a manual color to use for the color aesthetic, a character vector explictly specifying the colors to use for the color scale, or as the name of a palette to pass to |
adjust |
a numeric value to pass to |
size |
a numeric value to pass to |
Details
Plots a histogram of a score that ranges between 0 and 100, with the fill determined by some set categorization of the score. This is the function used to plot the distributions of disability scores resulting from the WHO Model Disability Survey.
Value
A density figure
See Also
Other figure functions:
fig_LID()
,
fig_dist()
,
fig_poppyramid()
Examples
fig_density(df_adults, score = "disability_score", cutoffs = c(19.1, 34.4, 49.6),
x_lab = "Disability score")
fig_density(df_adults, score = "disability_score", var_color = "sex",
cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score")
fig_density(df_adults, score = "disability_score", var_color = "sex",
var_facet = "age_cat", cutoffs = c(19.1, 34.4, 49.6), x_lab = "Disability score")