Reticulate: A new R package on GitHub using reticulate with a lot of Python scripts

Created on 24 Nov 2020  路  3Comments  路  Source: rstudio/reticulate

Hello,

Suppose I would like to develop an entire new R package on GitHub using package reticulate with a lot of Python scripts. Could you please tell what's the best way to do that ? where to put Python scripts, etc. ?

Thank you very much for your help !

All 3 comments

One possibility would be to look at the fairly impressive (and still growing strongly) list of reverse dependencies of reticulate and pick a few of those package to study.

@lbocken RStudio/Keras puts everything into inst/python/kerastools https://github.com/rstudio/keras/tree/master/inst/python/kerastools

In general, the strategy is:

  1. Place your Python scripts in inst/python/<module>, where <module> is typically derived from the package name;
  2. Use reticulate::import_from_path(module, path = system.file("python", package = "<package>") to import the module.

One such example from the Keras package: https://github.com/rstudio/keras/blob/aaddf0e411f66d48f88f858d1436c1d38e13fb97/R/model-custom.R#L21-L24

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AnthonyEbert picture AnthonyEbert  路  8Comments

dougmet picture dougmet  路  6Comments

myoung3 picture myoung3  路  7Comments

cb4github picture cb4github  路  5Comments

jjallaire picture jjallaire  路  9Comments