From: tsd@tsdye.com (Thomas S. Dye)
To: Charles Berry <ccberry@ucsd.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: cannot execute org-mode code from the front page tutorial.
Date: Sat, 16 Aug 2014 07:13:12 -1000 [thread overview]
Message-ID: <m2r40gs6hj.fsf@tsdye.com> (raw)
In-Reply-To: <loom.20140816T180546-339@post.gmane.org> (Charles Berry's message of "Sat, 16 Aug 2014 16:49:04 +0000 (UTC)")
Charles Berry <ccberry@ucsd.edu> 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
next prev parent reply other threads:[~2014-08-16 17:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-15 16:37 cannot execute org-mode code from the front page tutorial jenia.ivlev
2014-08-15 17:04 ` Thomas S. Dye
2014-08-15 18:40 ` Nick Dokos
2014-08-15 23:36 ` jenia.ivlev
2014-08-16 2:41 ` Nick Dokos
2014-08-16 2:43 ` Nick Dokos
2014-08-16 16:49 ` Charles Berry
2014-08-16 17:13 ` Thomas S. Dye [this message]
2014-08-16 21:01 ` Nick Dokos
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2r40gs6hj.fsf@tsdye.com \
--to=tsd@tsdye.com \
--cc=ccberry@ucsd.edu \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.