From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [Babel][R] buffer-wide and code block specific use of :session Date: Sat, 12 Feb 2011 18:30:58 +0000 Message-ID: References: <4D569D77.4020005@uni-koeln.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=49782 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoKFP-0004kl-Rh for emacs-orgmode@gnu.org; Sat, 12 Feb 2011 13:31:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoKFO-0000or-H8 for emacs-orgmode@gnu.org; Sat, 12 Feb 2011 13:31:07 -0500 Received: from mail-ew0-f41.google.com ([209.85.215.41]:54401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoKFO-0000nf-5R for emacs-orgmode@gnu.org; Sat, 12 Feb 2011 13:31:06 -0500 Received: by ewy27 with SMTP id 27so1691162ewy.0 for ; Sat, 12 Feb 2011 10:31:05 -0800 (PST) In-Reply-To: <4D569D77.4020005@uni-koeln.de> (Bernd Weiss's message of "Sat, 12 Feb 2011 09:47:19 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernd Weiss Cc: emacs-orgmode@gnu.org Bernd Weiss writes: > Org-mode version 7.4 (release_7.4.348.g6132) > > > Dear all, > > I am preparing a document which contains text and R code/output. In > particular, I'd like to print out a (correlation) matrix. This is my > org-mode document (I intentionally have two code blocks): > > #---------------------------------------------------------- > #+ Does not work > > #+BABEL: :session *R* > #+BEGIN_SRC R :results silent :tangle simcorrdata.R > cormat <- c(1.0, 0.2, 0.4, > 0.2, 1.0, -0.3, > 0.4, -0.3, 1.0) > cormat <- matrix(cormat, ncol = 3, byrow = TRUE) > #+END_SRC > > So, the correlation matrix looks as follows: > > #+BEGIN_SRC R :exports both :tangle simcorrdata.R > print(cormat) > #+END_SRC > #---------------------------------------------------------- > > Since I have two code blocks, I need to use :session. If I define > :session buffer-wide as > > #+BABEL: :session *R* > > then the matrix cormat is unknown within the second code block ("object > 'cormat' not found"). However, if I specify :session for each code block > seperately then it works as expected. Hi Bernd, The above does work for me. Some things to check: 1. After altering the #+BABEL line, it's necessary to refresh Org's file-local options, for example with C-c C-c on the #+BABEL line. (Same is true for #+OPTIONS, #+PROPERTY, etc) 2. I've just fixed a bug which was causing it to fail to work on the first attempt... But it did work on second and subsequent attempts. Please note that it is possible to make an equivalent setting using #+PROPERTY: session *R* In fact, I suspect we are going to drop #+BABEL entirely, so please consider it deprecated and use this form instead. After evaluating the first block, an ESS R buffer named *R* should exist, in which the variable cormat should be defined. Let me know if your problem persists. Dan > > #---------------------------------------------------------- > #+ Does work > > #+BEGIN_SRC R :session :results silent :tangle simcorrdata.R > cormat <- c(1.0, 0.2, 0.4, > 0.2, 1.0, -0.3, > 0.4, -0.3, 1.0) > cormat <- matrix(cormat, ncol = 3, byrow = TRUE) > #+END_SRC > > So, the correlation matrix looks as follows: > > #+BEGIN_SRC R :session :exports both :tangle simcorrdata.R > print(cormat) > #+END_SRC > #---------------------------------------------------------- > > > Does this happen due to my poor understanding of the :session argument? > Or is this a bug? > > Thanks for your help, > > Bernd > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode