emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] cannot execute org-mode code from the front page tutorial.


From: Thomas S. Dye
Subject: Re: [O] cannot execute org-mode code from the front page tutorial.
Date: Sat, 16 Aug 2014 07:13:12 -1000

Charles Berry <address@hidden> writes:

> Nick Dokos <ndokos <at> gmail.com> writes:
>
>> 
>> tsd <at> tsdye.com (Thomas S. Dye) writes:
>> 
>> > Aloha Jenia,
>> >
>> > jenia.ivlev <at> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]