zoukankan      html  css  js  c++  java
  • rPithon vs. rPython(转)

    Similar to rPython, the rPithon package (http://rpithon.r-forge.r-project.org) allows users to execute Python code from R and exchange the data between Python and R. However, the underlying mechanisms between these two packages are fundamentally different. Wihle rPithon communicates with Python from R through pipes, rPython accomplishes the same task with json. A major advantage of rPithon over rPython is that multiple Python processes can be started within a R session. However, rPithon is not very robust while exchanging large data objects between R and Python.

    rPython Session

     1 library(sqldf)
     2 df_in <- sqldf('select Year, Month, DayofMonth from tbl2008 limit 5000', dbname = '/home/liuwensui/Documents/data/flights.db')
     3 library(rPython)
     4 ### R DATA.FRAME TO PYTHON DICTIONARY ###
     5 python.assign('py_dict', df_in)
     6 ### PASS PYTHON DICTIONARY BACK TO R LIST
     7 r_list <- python.get('py_dict')
     8 ### CONVERT R LIST TO DATA.FRAME
     9 df_out <- data.frame(r_list)
    10 dim(df_out)
    11 # [1] 5000    3
    12 #
    13 # real  0m0.973s
    14 # user  0m0.797s
    15 # sys   0m0.186s

    rPithon Session

     1 library(sqldf)
     2 df_in <- sqldf('select Year, Month, DayofMonth from tbl2008 limit 5000', dbname = '/home/liuwensui/Documents/data/flights.db')
     3 library(rPithon)
     4 ### R DATA.FRAME TO PYTHON DICTIONARY ###
     5 pithon.assign('py_dict', df_in)
     6 ### PASS PYTHON DICTIONARY BACK TO R LIST
     7 r_list <- pithon.get('py_dict')
     8 ### CONVERT R LIST TO DATA.FRAME
     9 df_out <- data.frame(r_list)
    10 dim(df_out)
    11 # [1] 5000    3
    12 #
    13 # real  0m0.984s
    14 # user  0m0.771s
    15 # sys   0m0.187s
    ---------------------------------------------------------------------------------- 数据和特征决定了效果上限,模型和算法决定了逼近这个上限的程度 ----------------------------------------------------------------------------------
  • 相关阅读:
    pd_ds中的hash
    洛谷P1333 瑞瑞的木棍(欧拉回路)
    2-SAT速成
    洛谷P3209 [HNOI2010]PLANAR(2-SAT)
    BZOJ2199: [Usaco2011 Jan]奶牛议会(2-SAT)
    BZOJ 1823: [JSOI2010]满汉全席(2-SAT)
    IOS深入学习(1)之图标文件(icon files)
    控制反转思想的理解实例
    poj 3259 (Bellman_Ford判断负环)
    POJ 2686 Traveling by Stagecoach 壮压DP
  • 原文地址:https://www.cnblogs.com/payton/p/4390259.html
Copyright © 2011-2022 走看看