emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vikas Rawal <vikasrawal@gmail.com>
To: Naresh Gurbuxani <naresh_gurbuxani@hotmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Efficiently reuse code in org babel with R
Date: Thu, 7 Jul 2022 09:45:00 +0530	[thread overview]
Message-ID: <CALtzAB1y+RNQ_urQc=c4+YG-otesjsZ=LjyBt=cA7PmP-BDemQ@mail.gmail.com> (raw)
In-Reply-To: <BL0PR01MB403676CB85EEA1AD5724F07AFA839@BL0PR01MB4036.prod.exchangelabs.com>

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Why not specify a :session so that data created by one block would remain
available to subsequent blocks?

V.

On Thu, 7 Jul 2022 at 09:10, Naresh Gurbuxani <naresh_gurbuxani@hotmail.com>
wrote:

> I want to source some data from databases, then use this data in various
> blocks.  I am looking for the most efficient way to achieve this.  In below
> blocks, is the code in block ``connection'' executed thrice (economy of
> code but no saving of time) or is it only executed once then used twice?
> If the code is run thrice, is there another way to create code blocks so
> that the code is executed only once?
>
> Thanks,
> Naresh
>
> #+name: connection
> #+begin_src R :exports results :results output
>   ## my code here
> #+end_src
>
> #+begin_src R :exports results :results output graphics file :file
> figures/fig1.png
> <<connection>>
> ## my code here
> #+end_src
>
> #+begin_src R :exports results output graphics file :file figures/fig2.png
> <<connection>>
> ## my code here
> #+end_src
>

[-- Attachment #2: Type: text/html, Size: 1398 bytes --]

  reply	other threads:[~2022-07-07  4:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  3:31 Efficiently reuse code in org babel with R Naresh Gurbuxani
2022-07-07  4:15 ` Vikas Rawal [this message]
2022-07-07  8:42   ` Jeremie Juste
2022-07-07 12:09     ` Naresh Gurbuxani
2022-07-07  6:22 ` Greg Minshall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALtzAB1y+RNQ_urQc=c4+YG-otesjsZ=LjyBt=cA7PmP-BDemQ@mail.gmail.com' \
    --to=vikasrawal@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=naresh_gurbuxani@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).