%load_ext rmagic def f(x): return x + 2 f(2) %%R library(ggplot2) %%R head(iris) %%R ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point() %%R ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point(aes(color = Species)) %%R ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point() + geom_smooth(method = "lm", se = F) %%R ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) + geom_point() + geom_smooth(method = "lm", se = F)