Generate one or more barcharts to visualize the relationship between the loadings or mixture proportions and a selected categorical variable (a factor).
loadings_plot(
fit,
x,
k,
ggplot_call = loadings_plot_ggplot_call,
plot_grid_call = function(plots) do.call(plot_grid, plots)
)
loadings_plot_ggplot_call(dat, topic.label, font.size = 9)
An object of class “poisson_nmf_fit” or “multinom_topic_model_fit”.
A categorical variable represented as a
factor
. It should have the same number of elements as
the number of rows in fit$L
.
The topic, or topics, selected by number or name. When not specified, all topics are plotted.
The function used to create the plot. Replace
loadings_plot_ggplot_call
with your own function to
customize the appearance of the plot.
When multiple topics are selected, this is
the function used to arrange the plots into a grid using
plot_grid
. It should be a function accepting
a single argument, plots
, a list of ggplot
objects.
A data frame passed as input to
ggplot
, containing, at a minimum, columns
“x” and “loading”.
The name or number of the topic being plotted. Only used to determine the plot title.
Font size used in plot.
A ggplot
object.
This is a lightweight interface primarily intended to
expedite creation of boxplots for investigating relationships
between topics and a categorical variables of interest without
having to spend a great deal of time worrying about the plotting
settings; most of the “heavy lifting” is done by
‘ggplot2’ (specifically, function
geom_boxplot
in the ‘ggplot2’
package). For more control over the plot's appearance, the plot can
be customized by modifying the ggplot_call
and
plot_grid_call
arguments.