emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* calculate frequencies in a table with calc
@ 2012-12-25 12:59 Martin Gross
  2012-12-26  8:28 ` Achim Gratz
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Gross @ 2012-12-25 12:59 UTC (permalink / raw)
  To: emacs-orgmode

Dear helpers,

on the web I found a formula to get frequencies which I modified to my
needs, but it does not yet work well.  An example:

|---------------------|
| [1, 2, 3, 4, 5]     |
| [6, 7, 8]           |
| [9, 10, 11, 12, 12] |
| 12, 12              |
|---------------------|
| 15                  |
| 2                   |
#+TBLFM: @5$1=vcount(@I..@II)::@6$1=vcount(map(<if(eq(#1,12),1,[])>,@I..@II))

With the first formula (@5$1) everything inside and outside the
brackets is counted, but with the second (@6$1), where I am asking for
the frequency of 12, only what is outside the brackets is considered.
How could I also include what is inside the brackets, so I get 4?

Thank you very much in advance!

Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: calculate frequencies in a table with calc
  2012-12-25 12:59 calculate frequencies in a table with calc Martin Gross
@ 2012-12-26  8:28 ` Achim Gratz
  0 siblings, 0 replies; 3+ messages in thread
From: Achim Gratz @ 2012-12-26  8:28 UTC (permalink / raw)
  To: emacs-orgmode

Am 25.12.2012 13:59, schrieb Martin Gross:
> #+TBLFM: @5$1=vcount(@I..@II)::@6$1=vcount(map(<if(eq(#1,12),1,[])>,@I..@II))
>
> With the first formula (@5$1) everything inside and outside the
> brackets is counted, but with the second (@6$1), where I am asking for
> the frequency of 12, only what is outside the brackets is considered.
> How could I also include what is inside the brackets, so I get 4?

The Calc manual tells you that vcount flattens nested vectors, vmap doesn't.

Try @6$1=vcount(map(<if(eq(#1,12),1,[])>,vflat(@I..@II)))
for the second formula.


-- 
Achim.

(on the road :-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: calculate frequencies in a table with calc
@ 2012-12-27  8:57 Martin Gross
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Gross @ 2012-12-27  8:57 UTC (permalink / raw)
  To: emacs-orgmode

Dear Achim,

> Try @6$1=vcount(map(<if(eq(#1,12),1,[])>,vflat(@I..@II)))

Excellent. Thank you very much!

Sincerely,

Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-27  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-25 12:59 calculate frequencies in a table with calc Martin Gross
2012-12-26  8:28 ` Achim Gratz
  -- strict thread matches above, loose matches on Subject: below --
2012-12-27  8:57 Martin Gross

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).