emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Field coordinates and moving averages


From: Nick Dokos
Subject: Re: [O] Field coordinates and moving averages
Date: Tue, 15 Nov 2011 10:52:59 -0500

Benjamin Beckwith <address@hidden> 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(@address@hidden),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(@address@hidden)

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 via email to

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