i was making a plot with 15 plots in it. I tried par() but it seems that it doesn't work in a loop (or maybe I don't know how)
Here's my code:
vecB <- df2[,17:31]
for (i in seq_along(vecB)){
print(ggplot(vecB, aes(unlist(vecB[, i]), stat = "count"))
geom_bar(width = 0.65,
fill = "cadetblue3")
geom_text(stat = 'count', aes(label = ..count..),
vjust = -0.5, size = 3)
scale_y_continuous(limits = c(0, 225))
scale_x_continuous(limits = c(0.5, 5.5))
theme_light()
labs(x = paste('B', i, '作答分數'),
y = '次數')
)
}
I was wondering if there's a way to make a multiplot with a for loop. Thank you very much!
CodePudding user response: