reddit / emacs

calc functions for use with org-table formulas

SlowValue · 2022-05-31 20:11
Lately I used the formula `vcount(rdup(@I$1..@II$1))` to successfully count how many different numbers where in a column. Tidy. What calc functions do you know and are you using for org-table formulas? Maybe we can get a little list with examples for later reference?
SlowValue · 2022-05-31 20:11
A list of calc functions for org-table formulas to start with | name | description | example | |--------+--------------------------------+-------------------------------| | rdup | remove duplicates | rdup(@I$1..@II$1) | | sort | sort fields | sort(@I$1..@II$1) | | rsort | sort fields reverse | rsort(@I$1..@II$1) | | rev | reverse field | rev(@I$1..@II$1) | | head | get first cell | head(@I$1..@II$1) | | tail | get all but first cell | tail(@I$1..@II$1) | | eq | equal | eq(@2$1, @2$2) | | lt | less then | lt(@2$1, @2$2) | | find | find first field, which equals | find(@I$1..@II$1, @2$2) | | vsum | sum all fields | vsum(@I$1..@II$1) | | vlen | count fields | vlen(@I$1..@II$1) | | vcount | count fields | vcount(@I$1..@II$1) | | neg | negate all field values | neg(@I$1..@II$1) | | mul | verctor multiplication | mul(@I$1..@II$1, @I$2..@II$2) | | add | vector addition | add(@I$1..@II$1, @I$2..@II$2) | | vmean | calc mean value across fields | vmean(@I$1..@II$1) | table to try examples | foo | bar | |-----------+-----| | 5 | 3 | | 3 | 6 | | 2 | 1 | |-----------+-----| | 3.3333333 | | #+TBLFM: @5$1=vmean(@I$1..@II$1)