According to the rpy2
docs it should be possible to see interactive R output like this:
%%R
X=c(1,4,5,7)
Y = c(2,4,3,9)
summary(lm(Y~X))
Which is supposed to produce this:
Call:
lm(formula = Y ~ X)
Residuals:
1 2 3 4
0.88 -0.24 -2.28 1.64
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0800 2.3000 0.035 0.975
X 1.0400 0.4822 2.157 0.164
Residual standard error: 2.088 on 2 degrees of freedom
Multiple R-squared: 0.6993,Adjusted R-squared: 0.549
F-statistic: 4.651 on 1 and 2 DF, p-value: 0.1638
But despite being able to return nice-looking graphs from R using stuff like this SO answer, the R interactive output from summary
is not returned.
I can get round this by doing:
In [75]: %%R -o return_value
: X = c(1,4,5,7)
: Y = c(2,4,3,9)
: return_value = summary(lm(Y~X))
Then print
ing the returned value like this (although the output looks pretty bad because there are blank lines between each output line):
In [86]: print(return_value)
Call:
lm(formula = Y ~ X)
Residuals:
1 2 3 4
0.88 -0.24 -2.28 1.64
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0800 2.3000 0.035 0.975
X 1.0400 0.4822 2.157 0.164
Are the docs incorrect, or am I doing something wrong?