From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Question about using :cache in Babel (for R) Date: Tue, 27 Sep 2011 18:42:12 -0600 Message-ID: <87vcsdwl79.fsf@gmail.com> References: <1317156800.22065.YahooMailNeo@web161912.mail.bf1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8iFG-0006XQ-Sl for emacs-orgmode@gnu.org; Tue, 27 Sep 2011 20:43:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8iFF-0000Ar-GI for emacs-orgmode@gnu.org; Tue, 27 Sep 2011 20:43:30 -0400 Received: from mail-yw0-f41.google.com ([209.85.213.41]:54771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8iFE-0000Ah-VY for emacs-orgmode@gnu.org; Tue, 27 Sep 2011 20:43:29 -0400 Received: by ywe9 with SMTP id 9so6974091ywe.0 for ; Tue, 27 Sep 2011 17:43:28 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Michael Hannon Cc: Org-Mode List Michael Hannon writes: > Greetings. =C2=A0I have a question that relates to the use of the :cache = option in > Babel sessions using R. > > Here's the relevant configuration information: > > =C2=A0 =C2=A0 Emacs =C2=A0: GNU Emacs 23.2.1 (x86_64-redhat-linux-gnu, GT= K+ Version 2.24.4) > =C2=A0 =C2=A0 =C2=A0of 2011-05-23 on x86-12.phx2.fedoraproject.org > =C2=A0 =C2=A0 Package: Org-mode version 7.7 (release_7.7.328.g1a97) > > I've appended the text of a file that exhibits the issue, which is the > following. =C2=A0If I explicitly evaluate a given code block, using, let'= s say, C-c > C-c, I get the results stuck into the Org file, as in the first source-co= de > block below. =C2=A0If I then repeatedly export the file (to PDF, HTML, et= c.), I get > the cached results in the exported document. =C2=A0For instance, the mean= of the > random variable does not change as I repeatedly export the file. > > If for some reason I have NOT explicitly evaluated a given code block, as= with > the second code block below, then during export I see a message "Evaluati= ng > code block" (or similar), indicating that Babel is NOT using a cached ver= sion, > and no cacheable output is produced as a result, meaning that the entire > calculation will be repeated during the next export. =C2=A0For instance, = the mean > of the random variable will be different every time I export the file. > Hi Mike, This is the expected behavior. Org-mode files are just plain text, so if the results are not saved in the Org-mode file then there is no place to cache them. Since Org does not change the contents of Org-mode files the only way to save the result of a code block is to interactively evaluate the code block -- there is no way to generate and save cached results during export. > > I guess I can see the logic of this, but I wonder if there is some way to > instruct Babel to automatically cache the output of any code blocks it > evaluates, i.e., via a header argument or elisp variable or ... . > Nope, in the past we have played with things like an in-memory variable, but have abandoned such things as they would move away from the "just plain text" spirit of Org-mode, would require external storage on disk, and could ultimately lead to more confusing behavior than the current situation. > > Thanks, > > -- Mike > > P.S. Is the SHA1(?) identifier for the results a new feature? > No, this is how Babel knows if the contents of the code block have changed and hence if the cached results are still valid. Best -- Eric > > ---------- > > #+TITLE:=C2=A0 > #+AUTHOR: > #+DATE: > > #+STARTUP: hideblocks > #+BABEL: :session *R* :cache yes :results output verbatim :exports both > :tangle yes > > * This is a test > > #+begin_src R > > x =3D rnorm(10) > mean(x) > > #+end_src > > #+results[9b9372488662083d0d211b9aad9c2985faba20cd]: > : [1] -0.07904561 > > * Here's a second test > > #+begin_src R > > x =3D rnorm (50) > summary(x) > > #+end_src --=20 Eric Schulte http://cs.unm.edu/~eschulte/