From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id VhsfKRegRV8CFQAA0tVLHw (envelope-from ) for ; Tue, 25 Aug 2020 23:34:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eB5tJBegRV/LFgAA1q6Kng (envelope-from ) for ; Tue, 25 Aug 2020 23:34:47 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1746A940145 for ; Tue, 25 Aug 2020 23:34:46 +0000 (UTC) Received: from localhost ([::1]:48062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAiSj-0003hJ-CY for larch@yhetil.org; Tue, 25 Aug 2020 19:34:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAiSO-0003hB-0W for emacs-orgmode@gnu.org; Tue, 25 Aug 2020 19:34:24 -0400 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]:45991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAiSL-0004KB-Vp for emacs-orgmode@gnu.org; Tue, 25 Aug 2020 19:34:23 -0400 Received: by mail-il1-x12c.google.com with SMTP id k4so219778ilr.12 for ; Tue, 25 Aug 2020 16:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d476zCoCULKveHsbEBPJlqnIVjx+JP4QRtvkBGB87to=; b=aPN7USmKFeyu61a5SJJpDS2K12m3txcE+/vLFA1yZltKQvu400Q2HHjWWMhLcCqfj6 bV45eBHpfIamZzxctUFN96x12ILpEr5nejM0mE8rhfgjFktx7c6m0jUX65VCAKGGwGYI rP/qMD9gIeK3RIqhVDuqcL1tNgQNsCLXsWOmqdp4AF2n4DTUNk/Pr/HwCegpHHzua45Y PlAovZyGU+35BlxXVIi93COSy211w/mTB9oGFzCR2KUbATpYxaklTTLcSnFjqrTRk/Qe bTbYg5VRo/Hy/zJ2w2Estuo/dEsK6dUhhntBDKwtNBBiz3HwN5iW52q+qImUY+JYyTW/ 0I1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d476zCoCULKveHsbEBPJlqnIVjx+JP4QRtvkBGB87to=; b=rs6JqsIN78T0wnthypvwBgFw1SmxkKWhoMXx/s3d/mZ3ynkk91i5T4lne9Zr6XjEVQ OTsUmAb6aiHcusQYgEg9gH4hvBdaqxFBHrkA++o1OknQ64nHObfefcg7iBmUNCTrFBnr WgdmbgMBXsqD4KG9J+Rn8KViDSKRCdTSn00/ZFzp2uVWlErxCcX19rg+Ze2fW1sM1oXH btDGxNz6vILW9gdvzzNIIRT6YkAtW9FaPdl3OYQ4KNiRoihju5ETBR4nQUSLYck5RfdV rgx5o9PT7VlnT0Kjk7qAasjFmMZXO4ZrriZIREHEcvDEAFPghjstU2symtrZs7w4QKg6 WGMQ== X-Gm-Message-State: AOAM532jLGsP4qty/yQdTlMVE2knYuaSQmwl6yA1ve6FqzlC/pptWB4F yony1E2wroOe6MgwIrHqM1bbGYjmkakj10TV+Nk= X-Google-Smtp-Source: ABdhPJzidD6sSfeBirYHlpPdXNRfpYnhH64YuzbKAwz6xGt//zSBZ+yNyenDDg/r51JQzfAD9ZoA6cOQ1SFpZEPyEno= X-Received: by 2002:a92:de43:: with SMTP id e3mr10420140ilr.124.1598398460309; Tue, 25 Aug 2020 16:34:20 -0700 (PDT) MIME-Version: 1.0 References: <875z98gj4f.fsf@gmail.com> In-Reply-To: <875z98gj4f.fsf@gmail.com> From: Kyle Andrews Date: Tue, 25 Aug 2020 19:34:08 -0400 Message-ID: Subject: Re: [RFC] ob-reticulate: R+Python interface from Babel To: Jack Kamm Content-Type: multipart/alternative; boundary="0000000000006fbbe705adbc240a" Received-SPF: pass client-ip=2607:f8b0:4864:20::12c; envelope-from=kyle.c.andrews@gmail.com; helo=mail-il1-x12c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emacs orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=aPN7USmK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: IdrklPVaQ4pA --0000000000006fbbe705adbc240a Content-Type: text/plain; charset="UTF-8" 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 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 > > --0000000000006fbbe705adbc240a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Jack,

As = a frequent reticulate user I am very excited to see this patch. I hope othe= rs 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 allo= ws 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 packa= ge this separately. I'm also curious whether this would be useful to an= yone here. Any feedback is appreciated.

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

#+begin_src reticulate :session
=C2=A0 import pandas as pd

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

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

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

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

Cheers,
Jack

--0000000000006fbbe705adbc240a--