I would like to place two plots side by side using the ggplot2 package, i.e. do the equivalent of par(mfrow=c(1,2)).
par(mfrow=c(1,2))
For example, I would like to have t
Using tidyverse:
tidyverse
x <- rnorm(100) eps <- rnorm(100,0,.2) df <- data.frame(x, eps) %>% mutate(p1 = 3*x+eps, p2 = 2*x+eps) %>% tidyr::gather("plot", "value", 3:4) %>% ggplot(aes(x = x , y = value)) + geom_point() + geom_smooth() + facet_wrap(~plot, ncol =2) df