emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [babel] inline call within table formula?
Date: Sun, 10 Jul 2011 09:54:57 -0600	[thread overview]
Message-ID: <87aacmruyc.fsf@gmail.com> (raw)
In-Reply-To: 87wrfs6bro.fsf@ucl.ac.uk

Hi Eric,

The `sbe' macro can be used to evaluate code blocks in table formula.

For Example:

|   1 |
|   2 |
|   3 |
|   4 |
|   5 |
|   6 |
| 3.5 |
#+TBLFM: @7$1='(sbe mean (lst @1..@6))

#+source: mean
#+begin_src emacs-lisp :var lst=()
  (let ((num (car lst)) (nums (cdr lst)))
    (/ (float (+ num (apply #'+ nums))) (1+ (length nums))))
#+end_src

See the documentation string of this macro for more information.

Best -- Eric

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Hi,
>
> Quick question: I'd like to use a babel inline call to calculate
> something in a table based on other values in the table.  Is this
> possible?  Probably using elisp directly?  If so, I cannot figure out
> what the magic incantation should be!  I hope somebody can help.
>
> For illustration, I'd like to do something like this:
>
> #+source: f
> #+begin_src octave :var x=[1 3 5]
> sin(x)
> #+end_src
>
> | x1 | x2 | x3 | f                        |
> |----+----+----+--------------------------|
> |  1 |  3 |  5 | Apply call_f($1..$3) here |
>
> Thanks,
> eric

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

  reply	other threads:[~2011-07-10 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-08 15:19 [babel] inline call within table formula? Eric S Fraga
2011-07-10 15:54 ` Eric Schulte [this message]
2011-07-11  8:24   ` Eric S Fraga
2011-07-11  8:48     ` Sebastien Vauban
2011-07-11  9:03       ` Bastien
2011-07-11 10:01         ` Eric S Fraga
2011-07-11 15:23           ` Eric Schulte

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aacmruyc.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).