I have a loop that prints 4 ggplots, but I want to print all 4 in one grid. I have heard people use Multiplot, but I couldn't figure out how to use that within my loop.
This is my working code:
namesvector <- list("Start", "Week_1", "Week_3", "Week_5")
for (i in 4:ncol(data_3)) {
print(
ggplot(data_3, aes(
y = data_3[, i], x = Biomass, color = Tissue
)) +
geom_point() + geom_smooth(method = "lm") +
labs(title = namesvector[i - 3], x = "Biomass", y = "Isotopic Signature")
)
}
At the moment it prints all 4 plots individually: Example
Par mfrow c(2,2) also doesn't work.