Skip to content
Prev 370987 / 398500 Next

Help Required in looping visuals

I suspect you want to plot categorical variables in panels. Run the code below and see if it solves your problem. If not, create a minimal example as below and ask your question again.

df <- data.frame(set = factor(paste0("set", rep(1:6, each = 20))), 
                 x = rnorm(120), y = rnorm(120))
library(lattice)
xyplot(x~y|set, df, type = "p", as.table = TRUE)

library(ggplot2)
ggplot(df, aes(x = x, y = y, color = set)) +
  facet_wrap(~set, nrow = 2, ncol = 3) +
  geom_point()