From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: cannot execute org-mode code from the front page tutorial. Date: Sat, 16 Aug 2014 07:13:12 -1000 Message-ID: References: <8738cxvhe0.fsf@gmail.com> <87wqa9zjdl.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIhXt-0003ly-NI for emacs-orgmode@gnu.org; Sat, 16 Aug 2014 13:13:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIhXn-0006DU-Ga for emacs-orgmode@gnu.org; Sat, 16 Aug 2014 13:13:37 -0400 Received: from gproxy2-pub.mail.unifiedlayer.com ([69.89.18.3]:34588) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1XIhXn-0006D7-9P for emacs-orgmode@gnu.org; Sat, 16 Aug 2014 13:13:31 -0400 In-Reply-To: (Charles Berry's message of "Sat, 16 Aug 2014 16:49:04 +0000 (UTC)") 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: Charles Berry Cc: emacs-orgmode@gnu.org Charles Berry writes: > Nick Dokos gmail.com> writes: > >> >> tsd tsdye.com (Thomas S. Dye) writes: >> >> > Aloha Jenia, >> > >> > jenia.ivlev gmail.com (jenia.ivlev) writes: >> > >> >> Hello. >> >> >> >> I'm trying to go through the org-mode tutorial on its official page. >> >> > > [discussion showing that (if (listp value)...) generates a data.frame > deleted] > > [delete patch turning a data.frame into a vector] > >> And assuming this is correct, the worg page will need to be corrected >> too. >> > > No patch is needed. > > The point of the code in org-babel-R-assign-elisp is to create a data.frame > when `value' is a list. > > The patch adding `unlist(res)' turns it into an ordinary vector. > > This will break almost all uses of :var in R scr blocks. > > I don't think this example could have worked for a long while - turning > elisp lists into R data.frames has been a feature for a good while. > Also, note the use of `sbe' vs `org-sbe' in the formula. > > #+TBLFM: @2$1='(sbe "R-mean" (x "tbl-example-data()")) > > > Use `colMeans(x)' to fix the worg page. Also, it appears that babel no longer supports passing variables through the #+name: line. I don't use this syntax and can't remember now whether support for it was removed, or if it just withered away. At any rate, if I use the #+header: syntax then I can get the example working partially. It is possible then to get the OP's desired result with the #+call: line. Changing (sbe ...) to (org-sbe ...) in the table calculates the mean, but doesn't yield a real table. The initial "|" on the last line is missing. #+NAME: tbl-example-data #+BEGIN_SRC R :results value runif(n=5, min=0, max=1) #+END_SRC #+RESULTS: tbl-example-data | 0.850588989211246 | | 0.138243367196992 | | 0.382761054905131 | | 0.00688096368685365 | | 0.394350948277861 | #+NAME: R-mean #+header: :var x="" #+header: :results output #+BEGIN_SRC R colMeans(x) #+END_SRC #+call: R-mean(x=tbl-example-data) #+results: : V1 : 0.4273072 #+tblname: summaries | mean | |------| | V1 | 0.2574993| #+TBLFM: @2$1='(org-sbe "R-mean" (x "tbl-example-data()")) hth, Tom -- Thomas S. Dye http://www.tsdye.com