rownames lost in rendering/converting R data.frames

Issue #237 closed
Eric Meinhardt created an issue

Setup info:

  • Python: 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC v.1500 64 bit (AMD64)]

  • IPython: 2.1.0

  • IPython Notebook: 2.1.0

  • rpy2: 2.4.4

  • R: platform: x86_64-w64-mingw32, arch: x86_64, os: mingw32, system: x86_64, mingw32, status: "", major: 3, minor: 1.1, year: 2014, month: 07, day: 10, svn rev: 66115, language: R, version string: R version 3.1.1 (2014-07-10), nickname: Sock it to Me

Minimal example - each codeblock is an IPython Notebook cell input (observe the output for yourself):

Import packages:

import rpy2
%load_ext rpy2.ipython

Create a toy matrix:

y = matrix (1:12, nrow = 4, ncol = 3)
dimnames(y) <- list (c("Bob", "Dave", "Mary", "Sandy"), c("Blue", "White", "Red"))

Look at the matrix - note that the row and column labels are missing in the HTML rendering:

%R print(y)

Verify that the rownames are present on the R side:

%R rownames(y)

Create a dataframe from the matrix - note that the rownames do not appear in the indexing; instead, the indexing begins at 0:

%R tmp2 =
%R tmp2

Note that the rownames are, in fact, present in R:

%R rownames(tmp2)

Handing tmp2 to python does not fix the problem:

tmp3 = %R tmp2

Comments (4)

  1. Laurent Gautier
    • changed status to open

    Only an HTML rendering issue. The rownames are not lost during conversion.

    tmp2 = %R tmp2


    <StrVector - Python:0x7f4205b70d88 / R:0x2ec5000>
    ['Bob', 'Dave', 'Mary', 'Sandy']
  2. Log in to comment