emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] ob-reticulate: R+Python interface from Babel


From: Kyle Andrews
Subject: Re: [RFC] ob-reticulate: R+Python interface from Babel
Date: Tue, 25 Aug 2020 19:34:08 -0400

Hi Jack,

As a frequent reticulate user I am very excited to see this patch. I hope others feel the same and it gets included into org mode as I cannot wait to use it.

Best Regards,
Kyle

On Mon, Aug 24, 2020, 11:28 Jack Kamm <jackkamm@gmail.com> wrote:
Hi all,

Reticulate is an R package for interfacing between R and Python. It allows accessing objects in a Python session from R and vice versa. See https://rstudio.github.io/reticulate/ for more info about it.

I've written a small patch for using reticulate from org-babel. It allows creating a source block of lang "reticulate", which behaves as Python for font highlighting and editing, but is executed in an R session via reticulate.

I'm wondering whether this should go into org-mode, or whether to package this separately. I'm also curious whether this would be useful to anyone here. Any feedback is appreciated.

The main advantage of reticulate is being able to access Python objects directly from R and vice versa, without having to write them to a separate file or pass them through the ":var" header argument. For example, we could do the following:

#+begin_src reticulate :session
  import pandas as pd

  fib = [0, 1]
  for _ in range(10):
      fib.append(fib[-1] + fib[-2])

  df = pd.DataFrame({
      "i": list(range(len(fib))),
      "F_i": fib
  })
#+end_src

#+begin_src R :session :results graphics value file :file fig.png
  library(reticulate)
  with(py$df, plot(i, F_i))
#+end_src

Reticulate source blocks support both "value" and "output" results, and even supports graphics with matplotlib. It's primarily intended to be used in sessions, and the ":session" header argument should match between reticulate and R source blocks.

Cheers,
Jack


reply via email to

[Prev in Thread] Current Thread [Next in Thread]