Wrapping my brain around using #org-mode as a spreadsheet. Is there a way to pass a range of cells as a vector to a custom function? Ideally, I'd like to embed this function into the file itself. #emacs
That shows you how to define a column formula with elisp. I think think usual "vsum" and friends are vector operations from the emacs calculator, so it seems very likely?
I gotta go to the bike shop, but my heuristic would be:
1. I know vsum works in org-mode spreadsheet formulas 2. I know the v stands for "vector" 3. Can I use that function's source to define my own vector operations?
I like to think the answer is YES. I am hopeful at least.
@Shae Erisson So, of appears that I can pass simple (single cell) references into raw elisp functions, but not ranges. I'll have to have a closer look at vsum as mentioned earlier to see if there's a solution there.
I would be interested if you manage to read org tables as lisp lists. I haven't tried it yet, but I plan to do it occasionally, so cfw would get an org-table import/export. Currently it can do CSV.
Hi @me If you insert a formula in a table cell #orgmode will put it after the table in a special line (so you can see and edit it after) and insert the result in place. Of course, it can be recalculated anytime you want to.
Shae Erisson
in reply to Jonathan Lamothe • • •I WANT TO SHOW YOU MY TOYS!
I just did my 2024 taxes in org-mode spreadsheets!
Jonathan Lamothe
in reply to Shae Erisson • •Shae Erisson
in reply to Jonathan Lamothe • • •Yeah, I'd love to show you! I keep meaning to write a blog post.
In summary, table references are updated when that table's cells are reordered.
If another table refers to a cell in this table, that reference is not updated when the cell moves.
You can name a field! I was able to decipher this confusing illustration after an hour of staring: orgmode.org/org.html#Advanced-…
I'd already decided to do each tax form as its own spreadsheet: gist.github.com/shapr/84e37fdf…
Does the gist help?
A snippet of my taxes done in org-mode spreadsheets
GistShae Erisson
in reply to Jonathan Lamothe • • •Ahem, sorry about that excitement explosion.
Yes, you can call elisp functions, um, lemme find the reference
Shae Erisson
in reply to Jonathan Lamothe • • •Oh, as a vector? 🤔
Gosh I don't know about that.
orgmode.org/worg/org-tutorials…
That shows you how to define a column formula with elisp. I think think usual "vsum" and friends are vector operations from the emacs calculator, so it seems very likely?
Org as a spreadsheet system: a short introduction
orgmode.orgJonathan Lamothe
in reply to Shae Erisson • •Shae Erisson
in reply to Jonathan Lamothe • • •I gotta go to the bike shop, but my heuristic would be:
1. I know vsum works in org-mode spreadsheet formulas
2. I know the v stands for "vector"
3. Can I use that function's source to define my own vector operations?
I like to think the answer is YES. I am hopeful at least.
Jonathan Lamothe
in reply to Shae Erisson • •vsum
to see how it works. Internally it'scalcFunc-vsum
right?Shae Erisson
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Shae Erisson • •org-table-get-*
functions are showing some promise.Jonathan Lamothe
in reply to Shae Erisson • •vsum
as mentioned earlier to see if there's a solution there.Jonathan Lamothe
in reply to Jonathan Lamothe • •Shae Erisson
in reply to Jonathan Lamothe • • •I don't understand pivot tables, so I can't help.
What would this look like?
Jonathan Lamothe
in reply to Shae Erisson • •hajovonta
in reply to Jonathan Lamothe • • •Nice! I recently added pivottable functionality to #cfw but I don't think it would help you here.
It is since complete with transient menus and drilldown.
hajovonta
in reply to hajovonta • • •Jonathan Lamothe
in reply to hajovonta • •org-table-as-lisp
.Eduardo Mercovich (él)
in reply to Jonathan Lamothe • • •Hi @me
If you insert a formula in a table cell #orgmode will put it after the table in a special line (so you can see and edit it after) and insert the result in place. Of course, it can be recalculated anytime you want to.
But for a picot table, maybe you can also use org-aggregate? > github.com/tbanel/orgaggregate
GitHub - tbanel/orgaggregate: Aggregate tables in Org mode
GitHubLinus
in reply to Jonathan Lamothe • • •chuckadeus kummerer
in reply to Jonathan Lamothe • • •I like using org tables with org-babel like so:
#+NAME: test
| 1 | 4 |
| 2 | 5 |
| 3 | 6 |
#+begin src emacs-lisp :var test=test
(mapcar
'(lambda (r)
(mapcar '(lambda (x) (* x x)) r)) test)
#+end src
#+RESULTS:
| 1 | 16 |
| 4 | 25 |
| 9 | 36 |