3
votes

This question concerns the movement of data between cells in an org-mode table spreadsheet and an emacs calc vector.

I know that data can be pulled from a table and used in a function that takes a calc vector as input:

#+TBLFM: @2$4=vmean($2..$6)

I would like to go the other way and take the vector output from a function and write it to a range of cells in the spreadsheet, something like:

#+TBLFM: @2$1..@2$10=index(10)

(index is a a calc function that returns a calc vector with integers from 1 to n, the input to index)

But the table formula above puts the whole vector in every cell. How can I insert the vector elements into a cell range with one vector element per cell?

1

1 Answers

5
votes

Calc has a subscr function that will work:

Whole vector in one cell:

| [1, 2, 3, 4, 5] |
#+TBLFM: @1=index(5)

One vector element in each cell:

| 1 | 2 | 3 | 4 | 5 |
#+TBLFM: @1=subscr(index(5),$#)

This works for any calc function or custom calc function that returns a vector.