README.md

Rython

Embed python in R

Environment

Ubuntu with python 2.7

Please install the following ubuntu packages:

Usage

library(Rython)
py("python script")

Type Mapping

To pass object from R to python, use the following functions:

function name R type python type 1 pydict list dictionary 2 pylong integer list of long 3 pyfloat numeric list of float 4 pybool logical list of bool 5 pystr character list of str

API

Demo

cql 1.4

The following script query the Cassandra with python-cql 1.4 and pass the value back to R

library(Rython)
py("import cql")
py("con = cql.connect(host, port, key_space, cql_version='3.0.0')")
py("cursor = con.cursor()")
py("cursor.execute('select * from column_family limit 1')")
py("result = cursor.fetchall()")
py("print result")
py("result1 = result[0]")
result1 <- pyobj(obj_name="result1", module_name="")
pywrap(result1)

Demo for R package with python

Put your python script under inst/python and install it.

#'@export
.onLoad <- function(libname, pkgname) {
  import_pkg_module(pkgname, "foo.py")
}

NEWS



wush978/Rython documentation built on May 4, 2019, 12:02 p.m.