View source: R/covariate_plot.R
| covariate_plot | R Documentation |
Drawing a bin summary plot of covariates given a multinethist object with a user-specified order.
covariate_plot(
object,
covariate,
idx_order = 1:max(object$cluster),
main = NA,
xlab = NULL,
ylab = NA,
legend_title = NA,
stat = "count",
position = "stack"
)
summary_plot(object, covariate, ...)
object |
a |
covariate |
a vector for univariate covariate. If it is a factor, a stacked bar chart is drawn. If it is numeric, a violin plot is drawn. |
idx_order |
A numeric vector for index label order, which must be a permutation of |
main |
title of summary plot. If NA, the plot has no title. |
xlab |
label of x-axis. If |
ylab |
label of y-axis. If NA, y-axis label is "covariate" |
legend_title |
title of legend. If NA, the legend title is "covariate" |
stat |
variables pass to |
position |
variables pass to |
... |
currently unused. |
When covariate is a factor, a stacked bar chart is drawn with bins ordered by idx_order.
When covariate is numeric, a violin plot is drawn.
A ggplot object. Printed as a side effect. Returns the plot invisibly.
set.seed(42)
data(polblog)
nethist_polblog <- multinethist(polblog)
x <- factor(c(rep("Liberal", 586), rep("Conservative", 638)))
covariate_plot(nethist_polblog, x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.