emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* extract a column from a table but but an name on the new table
@ 2018-05-24 13:08 Uwe Brauer
  2018-05-26  7:20 ` Thierry Banel
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2018-05-24 13:08 UTC (permalink / raw)
  To: emacs-orgmode


Hi

Thierry Banel one of the authors of orgtbl-aggregate.el

Suggested to me the following code, if just want to extract one column
of a table.


#+TBLNAME: raw-data
| 1 | a | 3 |
| 2 | b | 4 |
| 3 | c | 6 |
| 4 | d | 7 |

#+BEGIN_SRC elisp :var data=raw-data
(mapcar (lambda (line)
            (list (nth 2 line)))
         data)
#+END_SRC

#+RESULTS:
| 3 |
| 4 |
| 6 |
| 7 |

It works nicely but how could I obtain the result with a table name,
like:

#+TBLNAME: RESULTS
| 3 |
| 4 |
| 6 |
| 7 |

Or something like this?

Thanks

Uwe Brauer 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: extract a column from a table but but an name on the new table
  2018-05-24 13:08 extract a column from a table but but an name on the new table Uwe Brauer
@ 2018-05-26  7:20 ` Thierry Banel
  2018-05-26  8:32   ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Thierry Banel @ 2018-05-26  7:20 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/html, Size: 2757 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: extract a column from a table but but an name on the new table
  2018-05-26  7:20 ` Thierry Banel
@ 2018-05-26  8:32   ` Uwe Brauer
  2018-05-27 13:06     ` Thierry Banel
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2018-05-26  8:32 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]




   > You may name the Lisp block like that:

   > --------------------------------------

   > #+TBLNAME: raw-data
   > | 1 | a | 3 |
   > | 2 | b | 4 |
   > | 3 | c | 6 |
   > | 4 | d | 7 |


Thank you!

BTW I found it strange that the extracting function does not exist in
vanilla org.


My situation is a bit different, since I later want to use R.

So I have


#+TBLNAME: raw-data
| 1 | a | 3 |
| 2 | b | 4 |
| 3 | c | 6 |
| 4 | d | 7 |

#+NAME: NotasA
#+BEGIN_SRC elisp :var data=raw-data
(mapcar (lambda (line)
            (list (nth 2 line)))
         data)
#+END_SRC

#+RESULTS: NotasA
| 3 |
| 4 |
| 6 |
| 7 |



#+begin_src R  :var notasA=notasA
summary(notasA)
#+end_src

And the last call does not work. It seems that R needs a table name.....

Uwe 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: extract a column from a table but but an name on the new table
  2018-05-26  8:32   ` Uwe Brauer
@ 2018-05-27 13:06     ` Thierry Banel
  2018-05-27 18:21       ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Thierry Banel @ 2018-05-27 13:06 UTC (permalink / raw)
  To: emacs-orgmode

On 26/05/2018 10:32, Uwe Brauer wrote:
>
>
>     > You may name the Lisp block like that:
>
>     > --------------------------------------
>
>     > #+TBLNAME: raw-data
>     > | 1 | a | 3 |
>     > | 2 | b | 4 |
>     > | 3 | c | 6 |
>     > | 4 | d | 7 |
>
>
> Thank you!
>
> BTW I found it strange that the extracting function does not exist in
> vanilla org.
You may like the out-of-the-boxtable remote references:

| 3 |
| 4 |
| 6 |
| 7 |
|   |
|   |
#+TBLFM: $1=remote(raw-data,@@#$3)

The downside is that you need to create an empty table with the right 
size before filling it with C-u C-c *

>
> My situation is a bit different, since I later want to use R.
>
> So I have
>
>
> #+TBLNAME: raw-data
> | 1 | a | 3 |
> | 2 | b | 4 |
> | 3 | c | 6 |
> | 4 | d | 7 |
>
> #+NAME: NotasA
> #+BEGIN_SRC elisp :var data=raw-data
> (mapcar (lambda (line)
>              (list (nth 2 line)))
>           data)
> #+END_SRC
>
> #+RESULTS: NotasA
> | 3 |
> | 4 |
> | 6 |
> | 7 |
>
>
>
> #+begin_src R  :var notasA=notasA
> summary(notasA)
> #+end_src
>
> And the last call does not work. It seems that R needs a table name.....
>
> Uwe
>

I get a result. Maybe you used downcase "notasA" where uppercase 
"NotasA" was expected?

#+begin_src R  :var notasA=NotasA
summary(notasA)
#+end_src

#+RESULTS:
| Min.   :3.00 |
| 1st Qu.:3.75 |
| Median :5.00 |
| Mean   :5.00 |
| 3rd Qu.:6.25 |
| Max.   :7.00 |

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: extract a column from a table but but an name on the new table
  2018-05-27 13:06     ` Thierry Banel
@ 2018-05-27 18:21       ` Uwe Brauer
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2018-05-27 18:21 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 575 bytes --]


   > On 26/05/2018 10:32, Uwe Brauer wrote:
   > You may like the out-of-the-boxtable remote references:

   > | 3 |
   > | 4 |
   > | 6 |
   > | 7 |
   > |   |
   > |   |

   > #+TBLFM: $1=remote(raw-data,@@#$3)

   > The downside is that you need to create an empty table with the right 
   > size before filling it with C-u C-c *


   > I get a result. Maybe you used downcase "notasA" where uppercase 
   > "NotasA" was expected?

You are right!! I did not pay attention!

Now it works, thanks very very much, that simplifies my workflow.

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-27 18:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24 13:08 extract a column from a table but but an name on the new table Uwe Brauer
2018-05-26  7:20 ` Thierry Banel
2018-05-26  8:32   ` Uwe Brauer
2018-05-27 13:06     ` Thierry Banel
2018-05-27 18:21       ` Uwe Brauer

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).