emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Naresh Gurbuxani <naresh_gurbuxani@hotmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Efficiently reuse code in org babel with R
Date: Thu, 7 Jul 2022 03:31:20 +0000	[thread overview]
Message-ID: <BL0PR01MB403676CB85EEA1AD5724F07AFA839@BL0PR01MB4036.prod.exchangelabs.com> (raw)

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

             reply	other threads:[~2022-07-07  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  3:31 Naresh Gurbuxani [this message]
2022-07-07  4:15 ` Efficiently reuse code in org babel with R Vikas Rawal
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=BL0PR01MB403676CB85EEA1AD5724F07AFA839@BL0PR01MB4036.prod.exchangelabs.com \
    --to=naresh_gurbuxani@hotmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).