emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Benjamin Beckwith <bnbeckwith@gmail.com>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: Field coordinates and moving averages
Date: Tue, 15 Nov 2011 10:52:59 -0500	[thread overview]
Message-ID: <26090.1321372379@alphaville.dokosmarshall.org> (raw)
In-Reply-To: Message from Benjamin Beckwith <bnbeckwith@gmail.com> of "Tue, 15 Nov 2011 10:21:40 EST." <878vnhpfw5.fsf@bnbeckwith.com>

Benjamin Beckwith <bnbeckwith@gmail.com> wrote:

> 
> I'm trying to create a table of periodic data and calculate a moving
> average in an adjacent column.  I was trying to use field coordinates,
> but they do not work how I would like them to work.
> 
> Here is what I have for a 5-day moving average:
> 
> | Daily Data | Moving Average |
> |------------+----------------|
> |         10 |                |
> |         11 |                |
> |         12 |                |
> |         13 |                |
> |         14 |                |
> |         14 |                |
> |         16 |                |
> #+TBLFM: $2=if(@# >=7, vmean(@-5$1..@0$1),string(""));
> 
> I expeced the if(@# >=7..) to protect the sub-clauses from executing
> unless the predicate is true.  However, that is not the case.  When I
> try to execute this formula, I receive the error: "Row descriptor -5
> used in line ### leads outside table".
> 
> I can see how this is true if the ranges are checked for every entry.
> Is there a better way for me to write this column forumla?  Is this a
> limitation in the field coordinates?
> 

Try a range on the LHS:

#+TBLFM: @7$2..@>$2=vmean(@-5$1..@0$1)

FWIW, I avoid calc conditionals because I don't really understand how
they work. E.g. you are assuming that it evals the condition and iff
true, it proceeds to eval one or the other of the clauses, but the lisp
error shows that that's not how it works. I prefer to deal with such
problems by writing a lisp function instead.

Nick

  reply	other threads:[~2011-11-15 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 15:21 Field coordinates and moving averages Benjamin Beckwith
2011-11-15 15:52 ` Nick Dokos [this message]
2011-11-15 19:16   ` Michael Brand

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=26090.1321372379@alphaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=bnbeckwith@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).