0

I am trying to plot ggplot matrix, the box plot version works just fine but when I try to do the same with ggplot I fail miserably

boxplot version:

par(mfrow=c(3, 3))
for (scale in c("POMS",
                "POMS_post",
                "DERS",
                "DERS_post",
                "REAPPRAISAL",
                "REAPPRAISAL_POST",
                "NEGATIV",
                "NEGATIVE_POST")) {
        boxplot(kata1[, scale] ~ Skupina, data=kata1, ylab=scale)
}

result of box plot version: enter image description here

ggplot version:

# Testing
for (scale in c("POMS",
                "POMS_post",
                "DERS",
                "DERS_post",
                "REAPPRAISAL",
                "REAPPRAISAL_POST",
                "NEGATIV",
                "NEGATIVE_POST")) {
        ggally_box(kata1, aes(Skupina, kata1[, scale])) # This does not work...
}

I think it should not be that difficult but I am stuck.

Thank you for help!

gofraidh
  • 673
  • 8
  • 26

1 Answers1

0

After a bit of playing this worked out, though it is kind of painful approach to add all those plots[[i]]. Thank you for help.

plots = NULL
for (scale in c("POMS",
                "POMS_post",
                "DERS",
                "DERS_post",
                "REAPPRAISAL",
                "REAPPRAISAL_POST",
                "NEGATIV",
                "NEGATIVE_POST")) {
        plots[[scale]] = ggally_box(kata1, aes_string("Skupina", scale, color = "Skupina"), 
                                    outlier.colour = "red",
                                    outlier.shape = 13)
        }

grid.arrange(plots[[1]],plots[[2]],
             plots[[3]],plots[[4]],
             plots[[5]],plots[[6]],
             plots[[7]],plots[[8]], ncol = 2)
gofraidh
  • 673
  • 8
  • 26