Is there a way to access R data frame column names in python/rpy2?
<p>I have an R data frame, saved in Database02.Rda. Loading it</p>

<pre><code>import rpy2.robjects as robjects
robjects.r.load("Database02.Rda")
</code></pre>

<p>works fine. However:</p>

<pre><code>print(robjects.r.names("df"))
</code></pre>

<p>yields</p>

<pre><code>NULL
</code></pre>

<p>Also, as an example, column 214 (213 if we count starting with 0) is named REGION. </p>

<pre><code>print(robjects.r.table(robjects.r["df"][213]))
</code></pre>

<p>works fine:</p>

<pre><code>Region 1   Region 2   ...
    9811       3451   ...
</code></pre>

<p>but we should also be able to do</p>

<pre><code>print(robjects.r.table("df$REGION"))
</code></pre>

<p>This, however, results in</p>

<pre><code>df$REGION 
        1
</code></pre>

<p>(which it does also for column names that do not exist at all); also:</p>

<pre><code>print(robjects.r.table(robjects.r["df"]["REGION"]))
</code></pre>

<p>gives an error:</p>

<pre><code>TypeError: SexpVector indices must be integers, not str
</code></pre>

<p>Now, the <a href="http://rpy2.readthedocs.org/en/version_2.7.x/vector.html?highlight=array#extracting-items" rel="noreferrer">docs</a> say, names can not be used for subsetting in python. Am I correct to assume that the column names are not imported whith the rest of the data when loading the data frame with python/rpy2? Am I thus correct that the easiest way to access them is to save and load them as a seperate list and construct a dict or so in python mapping the names to the column index numbers? This does not seem very generic, however. Is there a way to extract the column names directly?</p>

<p>The versions of R, python, rpy2 I use are: 
R: 3.2.2
python: 3.5.0
rpy2: 2.7.8</p>