R Basics
Just a demo, how R can be called from Sage to do something useful.
R Interpreter
[1] 1.0 2.0 3.0 -1.0 2.0 2.2
<class 'sage.interfaces.r.RElement'>
Min. 1st Qu. Median Mean 3rd Qu. Max.
-1.000 1.250 2.000 1.533 2.150 3.000
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.000 2.500 3.000 3.091 3.500 6.000
[1] 1
[1] 4
[1] 5 5 -2 5 -5 -4 -3 -4 1 -1 -1 -3 0 0 -2 1 -4 -2 -2 -2 -5 -5 -4 1 1 4 -2 -1 0 -4
Min. 1st Qu. Median Mean 3rd Qu. Max.
-5.00 -3.75 -2.00 -1.10 0.75 5.00
[1] 0 4 -1 -5 2 -2 -3 -4 3 1

Linear Regression
Call:
lm(formula = Y ~ X)
Residuals:
Min 1Q Median 3Q Max
-16.5313 -3.3934 -0.4112 3.0911 14.8677
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.2975 0.5098 -4.507 1.82e-05 ***
X 1.3803 0.1764 7.824 6.02e-12 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 5.094 on 98 degrees of freedom
Multiple R-squared: 0.3845, Adjusted R-squared: 0.3782
F-statistic: 61.21 on 1 and 98 DF, p-value: 6.019e-12