Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The error is because <code>%R</code> in IPython is attempting to turn the entire csv file into a single array of dtype float. The NA value in the integer column cannot be converted to a float, so an exception is raised.</p> <p>For example:</p> <pre><code>&gt;&gt;&gt; import rpy2.robjects as ro &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; myData = ro.r['read.csv']('data.csv') &gt;&gt;&gt; np.asarray(myData) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line 235, in asarray return array(a, dtype, copy=False, order=order) TypeError: __float__ returned non-float (type rpy2.rinterface.NAIntegerType) </code></pre> <p>A simple fix is to use the <code>--dataframe</code> / <code>-d</code> flag in <code>%R</code>. Note that we'll need to use the <code>--noreturn</code> / <code>-n</code> flag so ensure that we don't try to convert the return value into an array (which would again trigger the error). [Alternatively we could have put a semicolon at the end of the command.]</p> <p>For example:</p> <pre><code>In [1]: %load_ext rmagic In [2]: %R -n -d myData myData &lt;- read.csv('data.csv') In [3]: myData Out[3]: array([(1, 1, 1, 25, 0.590334, 0.4991572, 0.2189781, 9), (1, 1, 1, 25, 0.5504164, 0.5007439, 0.2136691, 13), (1, 1, 1, 25, 0.588486, 0.4879058, 0.2105431, 11), (1, 1, 1, 25, 0.5882244, 0.5148501, 0.2105431, -2147483648), (1, 2, 1, 25, nan, 0.489045, 0.2025757, 12)], dtype=[('replicate', '&lt;i4'), ('line', '&lt;i4'), ('genotype', '&lt;i4'), ('temp', '&lt;i4'), ('femur', '&lt;f8'), ('tibia', '&lt;f8'), ('tarsus', '&lt;f8'), ('SCT', '&lt;i4')]) </code></pre> <p>Beware that the <code>NAInteger</code> value was converted to <code>-2147483648</code> (which is equal to <code>numpy.iinfo('&lt;i4').min</code>).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload