Using Lisp to calculate spreadsheet in Emacs org table

Source: Internet
Author: User

In a word, nothing is weaker than Excel computing, and of course graphics is not. For programmers, using the mouse to drag or write the calculation formula with Lisp which is more in line with the habit of thinking, I think the latter. I will only introduce the Lisp calculation formula, if you focus on a simple Calc calculation formula, you can refer to the official document.


How to refer to other fields in a table

Recommended wording, @row_index $col _index

You can show or hide Row_index and col_index with c-c}

Like what:



How to insert a formula

First position the cursor to the cell you want to calculate, and then you can use the menu, tbl->calculat->set column Formular, or the combination key: C-c = or c-u c-c =

Then enter the formula in the mini buffer and press ENTER. The result is a formula that appears below the table:

* Test Form #+caption:dau Statistics | Date |   New |  daily life  | VV    | | --------+-------+-------+-------|| <6>    | <l5>  | <l5>  | <l5>  | |/      | | <     | >     |       | | 2015-05-01 | Ten | | | |    | | 2015-05-04 |  | | | | 119  |#+TBLFM: @6$4= ' (+ @4$4 @5$4); N

Note that the Lisp formula is used, which is preceded by a single quotation mark to prevent premature evaluation, which needs to be added later; N, which is said to be n mode, I don't quite understand this pattern at the moment.


How to Recalculate

C-u c-c * The entire table can be recalculated (the cursor must remain on the table) and the results are as follows:

#+caption:dau Statistics | Date |   New |  daily life  | VV    | | --------+-------+-------+-------|| <6>    | <l5>  | <l5>  | <l5>  | |/      | | <     | >     |       | | 2015-05-01 | | | | | | | 2015-05-04 | | | | | |       118   |#+TBLFM: @6$4 = ' (+ @4$4 @5$4); N



How to sum a column

There is a way to sum a column without writing a formula, position the cursor to a cell, then press C-C +, you will see the mini buffer prompt, and then press the S-insert key to automatically appear the sum value. Like what:

#+caption:dau Statistics | Date |   New |  daily life  | VV    | | --------+-------+-------+-------|| <6>    | <l5>  | <l5>  | <l5>  | |/      | | <     | >     |       | | 2015-05-01 | | | | | | |    | 2015-05-04 | |        | |     | |  |    |    118   |

But I still think the Lisp formula is better and easier to maintain because once the data has changed, you just need to recalculate the table once.

#+caption:dau Statistics | Date |   New |  daily life  | VV    | | --------+-------+-------+-------|| <6>    | <l5>  | <l5>  | <l5>  | |/      | | <     | >     |       | | 2015-05-01 | | | | | | 2015-05-04 | | | | | | | | | | |    117   |#+TBLFM: @6$2= ' (+ @[email protected]$2); N::@6$3= ' (+ @[email protected]$3); N::@6$4= ' (+ @[email protected]$4); N

First of all, there are three calculation formulas, which are used in the middle:: Separate

The fields value of the reference range can then be used: Represents the From: to semantics.

Finally, each time a value is modified, the table can be recalculated directly. This is a better way.


The above formula can also be optimized to use relative positions to specify the last line:

#+caption:dau Statistics |   Date | New  | daily Live  | VV    | conversion rate | | --------+-------+-------+-------+--------||    <6> | <l5>  | <l5>  | <l5>  |        | |      / | <     | > | | |        | 2015-05-01 |    | | 2015-05-04 | | 20 | | | |        | 2015-05-05 | |   | | | |        | | | | | | | | #+tblfm: @7$2= ' (+ @[email protected]$2); N::@7$3= ' (+ @[email protected]$3); N::@7$4= ' (+ @[email protected]$4); N

1 represents the previous line in the @7, so you can insert any number of lines in the middle, the formula only needs to modify the @7 to the correct number of rows, it can be calculated correctly.

Division

Elisp Division is/, when the outgoing floating point number as a floating-point division, if all are integers, it is divisible.

#+caption:dau Statistics |   Date | New | Daily Life |    VV |             Conversion rate | | --------+------+------+-------+--------------------||    <6> | | | | |                    |      / |    < |    > | | | |                    2015-05-01 |   One |   |    | |                    | 2015-05-04 |   One |   |    |                    | | 2015-05-05 |   |   |    | |                    | 2015-05-06 |   |   Bayi |  68.0 |                    | |    All |   |  161 | 235.0 | 1.4596273291925466 |#+tblfm: @8$2= ' (+ @[email protected]$2); N::@8$3= ' (+ @[email protected]$3); N::@8$4= ' (+ @[email protected]$4); N::@8$5= ' (/@8$4 @8$3); N



Using Lisp to calculate spreadsheet in Emacs org table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.