1

I'm new to org mode and have been using Orgtbl Aggregate for tables. I import space-separated files as org tables, add an hline to make the first row into a header, name them with #+NAME (aside: is there a better way to name a table than to just write this tag by hand above it?) and then I use org-insert-dblock:aggregate to aggregate data in a new table below.

My header-names have periods in them because they are LaTeX pgfplots-friendly. I can't use spaces, dashes, or underscores. The MWE below shows that Aggregate doesn't like the periods, and exhibits unpredictable behaviour when I try escaped quotes.

Can/should aggregate dblock work with the periods (how) or should I simply clean my headers first (this is what I ended up doing)?

#+NAME: mwe-table                                                                 |
| A | b.b | cc  |                                                                 |
|---+-----+-----|                                                                 |
| 1 |   3 |   4 |                                                                 |
| 1 |   4 |   5 |                                                                 |
| 2 |   6 |   7 |                                                                 |
| 2 |   8 |   9 |                                                                 |
#+BEGIN: aggregate :table "mwe-table" :cols "A mean(b.b) mean('b.b') mean(\"b.b\")"
| A | mean(b.b)                 | mean('b.b')                    |   mean("b.b") ||
|---+---------------------------+--------------------------------+---------------||
| 1 | error(7, '"Expected `)'") | error(6, '"Expected a number") | 80.6666666667 ||
| 2 | error(7, '"Expected `)'") | error(6, '"Expected a number") | 80.6666666667 ||
#+END:                                                                            |
#+BEGIN: aggregate :table "mwe-table" :cols "A mean(cc) mean(bb) mean(\'b.b\')"   |
| A | mean(cc) | mean(bb)  | mean('b.b')                    |                     |
|---+----------+-----------+--------------------------------|                     |
| 1 |      4.5 | vmean(bb) | error(6, '"Expected a number") |                     |
| 2 |        8 | vmean(bb) | error(6, '"Expected a number") |                     |
#+END:                                                                            |
  • Did you try replacing the names with :cols "A mean($1) mean($2) mean($3)"? – wvxvw Apr 10 '16 at 20:04
  • Yes, that works fine too, but in my real situation I have about 35 columns in several tables and would have to count them or move them. – Alejandro Erickson Apr 10 '16 at 20:09
  • I'd write to the library maintainer. Maybe they have a work-around for this, or will fix it, if this is a bug. I might be wrong, but it seems like orgtbl-to-aggregated-table-do-one-sum is responsible for doing the actual calculation and variable names are generated there. – wvxvw Apr 11 '16 at 6:02
0

A new version of orgtbl-aggregate is available on Melpa and https://github.com/tbanel/orgaggregate. Column names can now contain arbitrary characters (space, dot, semicolon, etc.). Just quote them with single or double quotes.

#+NAME: funnynames
| first column | observed;number | computed/expected |
|--------------+-----------------+-------------------|
| a/experiment |             2.3 |               2.4 |
| a/experiment |            15.4 |              12.1 |
| b/test       |           -98.7 |               0.0 |
....

#+BEGIN: aggregate :table "funnynames" :cols "\"first column\" mean('observed;number');%.3f mean('computed/expected');%.4f" :cond (>= (string-to-number "observed;number") 0)
| 'first column' | mean('observed;number') | mean('computed/expected') |
|----------------+-------------------------+---------------------------|
| a/experiment   |                   8.633 |                    7.1333 |
| b/test         |                   3.350 |                    3.1500 |
#+END:

To install from Melpa, add this to your .emacs file:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

then type M-x package-list and search for orgtbl-aggregate.

1

Funny column names have just not been anticipated. This can be a useful new feature. Your proposed syntax (single or double quotes) seems the way to go. I will look at how to implement that.

(The unexpected behavior you see when computing mean(\"b.b\") is actually mean([98,46,98]), which happen to be the ascii codes of b . b. Of course, this is hardly the expected result).

The author of orgtbl-aggregate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.