Skip to content

Instantly share code, notes, and snippets.

@xccds
Created July 20, 2014 02:35
Show Gist options
  • Save xccds/687d9baaf8baddb0408c to your computer and use it in GitHub Desktop.
Save xccds/687d9baaf8baddb0408c to your computer and use it in GitHub Desktop.
import numpy as np
x = np.random.randn(100)
y = 2*x + np.random.randn(100)
%load_ext rpy2.ipython
%%R -i x,y -w 500 -h 300
df <- data.frame(x,y)
m <- lm(y~x)
inter <- m$coef[1]
slop <- m$coef[2]
library(ggplot2)
p <- ggplot(df, aes(x,y))
p <- p +
geom_point() +
geom_abline(intercept = inter, slope = slop)
print(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment