Create a bar plot based on categorical (one or two) variables and one numeric variable.
plot_factbars(
.data,
...,
resp,
y.expand = 1,
y.breaks = waiver(),
xlab = NULL,
ylab = NULL,
lab.bar = NULL,
lab.bar.hjust = 0.5,
lab.bar.vjust = -0.5,
lab.bar.angle = 0,
size.text.bar = 5,
lab.x.hjust = 0.5,
lab.x.vjust = 1,
lab.x.angle = 0,
errorbar = TRUE,
stat.erbar = "se",
width.erbar = 0.3,
level = 0.95,
invert = FALSE,
col = TRUE,
palette = "Spectral",
width.bar = 0.9,
legend.position = "bottom",
size.text = 12,
fontfam = "sans",
na.rm = TRUE,
verbose = FALSE
)
The data set
A comma-separated list of unquoted variable names. Must be up to two variables.
The response variable
A multiplication factor to expand the y axis.. Defaults to 1.
The breaks to be plotted in the y-axis. Defaults to waiver().
authomatic breaks
. The same arguments than x.breaks
can be
used.
The x label
The y label
A vector of characters to show in each bar. Defaults to NULL.
The horizontal and vertical adjust for the labels in the bar. Defaults to 0.5 and -0.5, respectively.
The angle for the labels in the plot. Defaults to 0. Use
in combination with lab.bar.hjust
and lab.bar.vjust
to best
fit the labels in the plot.
The size of the text in the bar labels.
The horizontal and vertical adjust for the labels in the bar. Defaults to 0.5 and 1, respectively.
The angle for the labels in x axis. Defaults to 0. Use
in combination with lab.x.hjust
and lab.x.vjust
to best
fit the labels in the axis.
Logical argument, set to TRUE. In this case, an error bar is shown.
The statistic to be shown in the errorbar. Must be one of
the stat.erbar = "se"
(standard error, default), stat.erbar =
"sd"
(standard deviation), or stat.erbar = "ci"
(confidence
interval), based on the confidence level in the argument level
.
The width of the error bar.
The confidence level
Logical argument. If TRUE
, the order of the factors
entered in changes in the graph
Logical argument. If FALSE
, a gray scale is used.
The color palette to be used. For more details, see
?scale_colour_brewer
The width of the bars in the graph. Defaults to 0.9 possible values [0-1].
The position of the legend in the plot.
The size of the text
The family of the font text
Should 'NA' values be removed to compute the statistics? Defaults to true
Logical argument. If TRUE a tibble containing the mean, N, standard deviation, standard error of mean and confidence interval is returned.
An object of class gg, ggplot
.
# NOT RUN {
library(metan)
plot_factbars(data_ge2,
GEN,
ENV,
resp = PH)
# }
Run the code above in your browser using DataLab