histbxp | R Documentation |
The function creates a figure having both an histogram and a boxplot for a random variable, as a way to help understanding its distribution.
histbxp(
y = y,
freqlab = "Frequency",
varlab = "Variable",
eng = TRUE,
refval = NA,
print.refval = FALSE,
col.hist = "gray",
col.bxp = "gray",
portrait = TRUE,
oma = c(3, 0.5, 2, 0),
mar = c(1, 4, 0.2, 1),
cex.varlab = 1.2,
refval.symbol = expression(bar(y)),
col.refval = "blue",
varlim = NA,
freqlim = NA
)
y |
A numeric vector representing the random variable. |
freqlab |
(optional) A string specifying the frequency label. The default is set to "Frequency". |
varlab |
(optional) A string specifying the random variable label. The default is set to "Variable". |
eng |
logical; if "TRUE" (by default), the language of some default text will be in English; if "FALSE" will be in Spanish. The default is to "TRUE". |
refval |
A numeric value to be used for printing as reference
for the random variable. By default is set to the mean of the
variable |
print.refval |
A logical statement to define whether a
reference value should be printed, if set to TRUE, the
mean of the |
col.hist |
A string specifying the histogram color. The default is "gray". |
col.bxp |
A string specifying the boxplot color. The default is "gray". |
portrait |
A logical statement, if set to TRUE, the boxplot will be located under the histogram (2 rows, 1 column). If is set to FALSE, the boxplot will be located next to the histogram (1 row, 2 columns). The default is TRUE. |
oma |
As in the plot environment. The default
is |
mar |
As in the plot environment. The default
is |
cex.varlab |
A numeric value for the |
refval.symbol |
A string of type |
col.refval |
A string specifying the |
varlim |
(optional) A numeric vector having the minimum and maximum, respectively for the random variable. |
freqlim |
(optional) A numeric vector having the minimum and maximum, respectively for the frequency axis. |
The variable must be numeric.
The function returns the above described graph.
Christian Salas-Eljatib
Salas-Eljatib C. 2021. Análisis de datos con el programa estadístico R: una introducción aplicada. Ediciones Universidad Mayor. Santiago, Chile. 170 p. https://eljatib.com
Salas C, Stage AR, and Robinson AP. 2008. Modeling effects of overstory density and competing vegetation on tree height growth. Forest Science 54(1):107-122. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/forestscience/54.1.107")}
df <- datana::fishgrowth
histbxp(y=df$length)
### distribution of 'length'
## with mean refval
histbxp(y=df$length, print.refval = TRUE)
## with given refval
histbxp(y=df$length, print.refval = TRUE, refval = 250)
## changing labels
histbxp(y=df$length, print.refval = TRUE, refval = 250,
freqlab = "FREQ", varlab = "LENGTH")
## changing colors
histbxp(y=df$length, print.refval = TRUE, refval = 250,
freqlab = "FREQ", varlab = "LENGTH",
col.hist = "blue",
col.bxp = "green",
col.refval = "red")
### distribution of 'scale'
## with mean refval
histbxp(y=df$scale, print.refval = TRUE)
## landscape mode
histbxp(y=df$scale, print.refval = TRUE, portrait = FALSE)
## with limits
histbxp(y=df$scale, print.refval = TRUE, portrait = FALSE,
freqlim = c(0,100),
varlim = c(0, max(df$scale)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.