In [1]:
%load_ext rpy2.ipython
In [2]:
%%R
X = c(1,2,3,4,5)
Y = c(1,2,3,6,5)
s = capture.output(summary(lm(Y~X)))
In [3]:
a =%R s
for line in a[2:-1]:
         print(line )
lm(formula = Y ~ X)

Residuals:
         1          2          3          4          5 
 1.239e-17 -2.000e-01 -4.000e-01  1.400e+00 -8.000e-01 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)  
(Intercept)  -0.2000     1.0132  -0.197   0.8561  
X             1.2000     0.3055   3.928   0.0294 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.9661 on 3 degrees of freedom
Multiple R-squared:  0.8372,	Adjusted R-squared:  0.7829 
F-statistic: 15.43 on 1 and 3 DF,  p-value: 0.02937
In [4]:
%R plot(X,Y)