Created
February 17, 2016 02:07
-
-
Save padamson/3ce8174228d5607b78be to your computer and use it in GitHub Desktop.
Add two regression lines to plots in ggpairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(datasets) | |
data("swiss") | |
require(GGally) | |
require(ggplot2) | |
my_fn <- function(data, mapping, ...){ | |
p <- ggplot(data = data, mapping = mapping) + | |
geom_point() + | |
geom_smooth(method=loess, fill="red", color="red", ...) + | |
geom_smooth(method=lm, fill="blue", color="blue", ...) | |
p | |
} | |
g = ggpairs(swiss,columns = 1:4, lower = list(continuous = my_fn)) | |
g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment