par(mfrow) not creating multiple graphs in single plot

Hi,

I'm very new to R so am unfortunately a bit clueless currently. I'm trying to plot multiple graphs in the single window using the par() function, but it just doesn't work. If anyone could help I'd really appreciate it!

> library(tidyverse)

> par(mfrow=c(1,2))

> ggplot(data = mpg) +
+     mapping = aes(x = displ, y = hwy, colour = drv),
+     show.legend = FALSE
+   )
`geom_smooth()` using method = 'loess' and formula 'y ~ x'

> ggplot(data = mpg) +
+     mapping = aes(x = displ, y = hwy, colour = drv))
`geom_smooth()` using method = 'loess' and formula 'y ~ x'

Hi,

is a command for base R plotting and will not work in interplay with the {ggplot2} package. If you want to combine ggplots, have a look at the patchwork and cowplot packages.

1 Like

You're welcome! Please mark the topic as solved if this is the case.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Well that makes a lot of sense. Thank you!

1 Like