Conversion of R factors to column in a pandas DataFrame [Was: 'blue']

Issue #236 resolved
Big Stone
created an issue

doing the first example of dplyr, I don't succeed to get 'blue', I get 1 instead :

from rpy2.robjects import vectors, RObject,  SignatureTranslatedFunction, r
r('''
df <- data.frame(
color = c("blue", "black", "blue", "blue", "black"),value = 1:5)
filter(df, color == "blue") 
''')

r_blue.GIF

Comments (7)

  1. Laurent Gautier

    Fixed. Note that triggering the HTML rendering one has to do:

    from rpy2.robjects import vectors, RObject,  SignatureTranslatedFunction, r
    dataf = r('''
    require(dplyr, quiet=TRUE)
    df <- data.frame(
    color = c("blue", "black", "blue", "blue", "black"),value = 1:5)
    filter(df, color == "blue") 
    ''')
    
    # HTML rendering
    import rpy2.ipython.html
    rpy2.ipython.html.init_printing()
    
    dataf
    
  2. Big Stone reporter

    Merci ! Unfortunately, I'm stuck on 2.4 because of Christoph Gohlke.

    Looking for workarounds will be painfull.

    By the way, the "INSTALL_WINDOWS" page may need its annual refresh :

    from RHOME: C:\Program Files\R\R-2.13.1

    to RHOME: C:\Program Files\R\R-3.1.2

  3. Log in to comment