In [1]:
%pylab inline
%load_ext rmagic


Populating the interactive namespace from numpy and matplotlib
/usr/local/anaconda/lib/python2.7/site-packages/IPython/extensions/rmagic.py:693: UserWarning: The rmagic extension in IPython is deprecated in favour of rpy2.ipython. If available, that will be loaded instead.
http://rpy.sourceforge.net/
  warnings.warn("The rmagic extension in IPython is deprecated in favour of "

In [2]:
N = 15
x1 = [49., 50, 45, 53, 69, 73, 35, 40, 36, 30, 49, 36, 73, 61, 74]
Y = [ 132.03, 98.64, 146.24, 97.9, 145.12, 191.78, 155.34, 123.08, 140.87,
      122.51, 146.08, 89.3, 134.52, 89.16, 136.08]

In [4]:
%%R -i x1,Y -o X
XYfit = lm(Y~x1)
X = model.matrix(XYfit)

In [8]:
%R 1 + 2


Out[8]:
<FloatVector - Python:0x7f25dd2cfdd0 / R:0x40235f8>
[3.000000]

In [9]:
%R x = 1
%R x


Out[9]:
<FloatVector - Python:0x7f25dd2cf8c0 / R:0x4038288>
[1.000000]

In [10]:
%R # this is a comment

In [14]:
%R x = 1; y = 2; z = 3
%R v = x > y
%R u = TRUE
%R u


Out[14]:
<Vector - Python:0x7f25faeab440 / R:0x422eb78>
[       1]

In [28]:
%R a = c(1, 2, 3, 4, 5, 6, 7, 8, 9)
%R b = c(9, 8, 7, 6, 5, 4, 3, 2, 1)
%R a[1] / b[8]


Out[28]:
<FloatVector - Python:0x7f25dd2bedd0 / R:0x373b588>
[0.500000]

In [42]:
a = np.arange(20)
b = np.arange(20, 0, -1)

In [43]:
%%R -i a,b
s = a[2:4] / b[18:20]
s^4


[1]  0.01234568  1.00000000 81.00000000

In [44]:
%R a


Out[44]:
<Array - Python:0x7f25dd2cf7a0 / R:0x351bf28>
[       0,        1,        2, ...,       17,       18,       19]

In [ ]: