emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: edgar@openmail.cc
To: emacs-orgmode@gnu.org
Subject: how to concatenate string to spreadsheet formula
Date: Mon, 15 Aug 2022 13:50:59 +0000	[thread overview]
Message-ID: <20220815135059.Horde.0yrWgPRhFF6o7SxGXFD4fgW@www.vfemail.net> (raw)

Dear everyone,

At the moment, I am using an Org spreadsheet to concatenate a string  
to the ratio between 2 numbers. One of numbers is the  
[[sum-of-column][sum of a column]]. The other number would correspond  
to [[each-row-col1][each of the rows of another column]]  
([[ratio-to-0.95][multiplied by a factor]])
1. <<sum-of-column>>calculate the sum of a column
    - originally wanted vsum
    - corresponding part: =(reduce '+ (mapcar 'string-to-number (list  
@5$<..@6$<)))=
2. <<each-row-col1>>each of the values in column 1
    (string-to-number $1)
3. <<ratio-to-0.95>>the ratio between [[each-row-col1]] and  
[[sum-of-column]] is multiplied by 0.95

The final value is concatenated with "\\textwidth".

| width | height |      w / Σw |                   w / pic_row |
|   204 |    120 |  0.10418795 |                    0.32606557 |
|   215 |    125 |  0.10980592 |                    0.34364754 |
|   191 |    119 | 0.097548519 |                    0.30528689 |
|   483 |    125 |  0.24668029 |  0.7294912559614499\textwidth |
|   146 |    128 | 0.074565884 | 0.22050874403854998\textwidth |
|   719 |    101 |  0.36721144 |                               |
|-------+--------+-------------+-------------------------------|
|  1958 |    718 |             |                               |
#+tblfm: @5$4..@6$4='(concat (number-to-string (* 0.95  
(string-to-number (math-format-number (math-div (string-to-number $1)  
(reduce '+ (mapcar 'string-to-number (list @5$<..@6$<))))))))  
"\\textwidth")

Is there a more succint way of doing this? For instance, my original  
intention was to have something like

     #+tblfm: @5$4..@6$4=vsum($1 / vsum(@5$<..@6$<);"%0.4f\\textwidth"

which does not work. I would also like to avoid creating another  
column (=#+tblfm: @5$4..@6$4=vsum($1 /  
vsum(@5$<..@6$<);%0.4f::@<<$5..@>>$5='(concat $4 "\\textwidth")=).

Thank you very much!


-------------------------------------------------
This free account was provided by VFEmail.net - report spam to abuse@vfemail.net
 
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  


             reply	other threads:[~2022-08-15 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 13:50 edgar [this message]
2022-08-15 14:40 ` how to concatenate string to spreadsheet formula Fraga, Eric
2022-08-16  8:22   ` edgar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220815135059.Horde.0yrWgPRhFF6o7SxGXFD4fgW@www.vfemail.net \
    --to=edgar@openmail.cc \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).