# Load necessary library
library(ggplot2)
# Create example ggplot objects
plot1 <- ggplot(mtcars, aes(x=mpg, y=wt)) + geom_point()
plot2 <- ggplot(mtcars, aes(x=mpg, y=cyl)) + geom_point()
plot3 <- ggplot(mtcars, aes(x=gear, y=wt)) + geom_point()
# Plot all three plots in a single row
multiplot(plot1, plot2, plot3, cols=3)
# Plot using a custom layout
layout_matrix <- matrix(c(1,2,3,3), nrow=2, byrow=TRUE)
multiplot(plotlist=list(plot1, plot2, plot3), layout=layout_matrix)
Run the code above in your browser using DataLab