bm is my dataset, I want to loop through the dataset, each time I take the column name and make a plot
for (i in colnames(bm)) {
print(i)
print(plot_xtab(bm$y,
bm$i,
margin = "row",
bar.pos = "stack",
axis.titles = "Deposit Subscription",
legend.title = 1,
show.values = TRUE,
show.n = FALSE,
geom.size = 0.5, expand.grid = TRUE, vjust = "right"))
}
The following code works where contact is my first column title/name
print(plot_xtab(bm$y,
bm$contact,
margin = "row",
bar.pos = "stack",
axis.titles = "Deposit Subscription",
legend.title = 1,
show.values = TRUE,
show.n = FALSE,
geom.size = 0.5, expand.grid = TRUE, vjust = "right"))
And I have tested to find that the i output in the loop do shows the correct column titles: "contact", "job",etc; don't know why bm$i returns NULL