Skip to main content

Enables importing R packages and files (like python modules) in python syntax via rpy2.

Project description

Python-style imports of R files and packages

An rpy2 wrapper package to enable Python-style imports of R files and packages and expose them as commandline tools (based on python-fire), including automatic pandas object conversion if it is installed.

Setup

pip install import-r

Usage

Import any R installed package or R file in your working dir or on either $RPYPATH or $R_LIBS paths like any other python module:

    from r import test
    import r.test as rtest
    from r import ggplot2
    import r
    r.path.append('dir/to/my/rfiles')
    from r import my_rfile

Commandline interface

Install with cli support (pip install import-r[rcli]) and then use R files and packages on the commandline like this:

    rcli utils install_packages ggplot2
    rcli path/to/my/rfile.R function1 --arg=2 --flag

Test and release

pip install .[test]
pytest
python setup.py sdist
twine upload dist/*

Once everything passed successfully, tag and push to github:

version=0.1
git commit -m "Release v${version}"
git tag "v$version"
git push; git push --tags

Credit

Michel Wortmann michel.wortmann@ouce.ox.ac.uk

MIT Licence

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

import-r-0.2.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file import-r-0.2.tar.gz.

File metadata

  • Download URL: import-r-0.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for import-r-0.2.tar.gz
Algorithm Hash digest
SHA256 cecff5af495901f9d9c49e531d3d477c5bafd4a7d2196d063101066a01e479ff
MD5 42590dc8bda017d292589f03259925d8
BLAKE2b-256 2b61f0275e3d1d48e272e4f918afbb2d14eb93aa081010491bf37d769605d81d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page