[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How modify numbers in a region by a multiplier?
From: |
Dan Davison |
Subject: |
Re: How modify numbers in a region by a multiplier? |
Date: |
Thu, 01 Jul 2010 11:01:09 -0400 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) |
Juanma Barranquero <lekktu@gmail.com> writes:
> On Thu, Jul 1, 2010 at 15:55, Seweryn Kokot <sewkokot@gmail.com> wrote:
>
>> Imagine that I have some numbers
>>
>> 33.444 3333 4433.4443 3344 .34234
>>
>> and I want them multiplied for example by 0.1
>>
>> to receive
>>
>> 3.3444 333.3 443.34443 334.4 .034234
Here are three solutions using Org-mode.
* Using the Org spreadsheet
http://orgmode.org/org.html#The-spreadsheet
http://orgmode.org/worg/org-tutorials/org-spreadsheet-intro.php
Leave second column blank; issue C-u C-c C-c with point in the table
| 33.444 | 3.3444 |
| 3333 | 333.3 |
| 4433.4443 | 443.34443 |
| 3344 | 334.4 |
| 0.34234 | 0.034234 |
#+tblfm: $2=$1*0.1
* Using Org-babel
http://orgmode.org/worg/org-contrib/babel/index.php
Unless using Org from git it's in the Org contrib directory; Org-babel
is integrated into Org in the git HEAD and so in the next Org release,
with a new manual chapter.
Use C-c C-c on the source code blocks to generate the results tables.
#+tblname: tab
| 33.444 | 3333 | 4433.4443 | 3344 | .34234 |
** Using emacs lisp
#+begin_src emacs-lisp :var X=tab
(mapcar (lambda (x) (* 0.1 x)) (car X))
#+end_src
#+results:
| 3.3444000000000003 | 333.3 | 443.34443000000005 | 334.40000000000003 |
0.034234 |
** Using R
#+begin_src R :var X=tab
X * 0.1
#+end_src
#+results:
| 3.3444 | 333.3 | 443.34443 | 334.4 | 0.034234 |
Dan
>
> Interactively, you can try with some variation of
>
> M-x replace-regexp \([0-9.]+\) <RET> \,(/ (string-to-number \1) 10.0) <RET>
>
> Juanma
- Re: How modify numbers in a region by a multiplier?, (continued)
- Re: How modify numbers in a region by a multiplier?, Juanma Barranquero, 2010/07/01
- Re: How modify numbers in a region by a multiplier?, Seweryn Kokot, 2010/07/02
- Re: How modify numbers in a region by a multiplier?, Juanma Barranquero, 2010/07/02
- Re: How modify numbers in a region by a multiplier?, Seweryn Kokot, 2010/07/02
- Re: How modify numbers in a region by a multiplier?, Juanma Barranquero, 2010/07/02
- Re: How modify numbers in a region by a multiplier?, Štěpán Němec, 2010/07/02
- Re: How modify numbers in a region by a multiplier?, Juanma Barranquero, 2010/07/02
- Re: How modify numbers in a region by a multiplier?, Seweryn Kokot, 2010/07/05
- Re: How modify numbers in a region by a multiplier?, Juanma Barranquero, 2010/07/05
- Re: How modify numbers in a region by a multiplier?, Seweryn Kokot, 2010/07/05
Re: How modify numbers in a region by a multiplier?,
Dan Davison <=
Re: How modify numbers in a region by a multiplier?, Qiang Guo, 2010/07/01