From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Pizzolli Subject: Re: [PATCH] inline src block results can be removed Date: Mon, 24 Nov 2014 10:48:40 +0100 Message-ID: References: <87egt81acy.fsf@gmail.com> <8761ejq9ek.fsf@nicolasgoaziou.fr> <87sihltt3v.fsf@selenimh.mobile.lan> <87zjbqrapy.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsqGO-0005Nf-Ue for emacs-orgmode@gnu.org; Mon, 24 Nov 2014 04:49:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XsqGE-0001sn-Of for emacs-orgmode@gnu.org; Mon, 24 Nov 2014 04:48:56 -0500 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:35280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsqGE-0001sD-Et for emacs-orgmode@gnu.org; Mon, 24 Nov 2014 04:48:46 -0500 In-Reply-To: <87zjbqrapy.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Charles C. Berry" , Aaron Ecay , Andreas Leha , emacs-orgmode@gnu.org, Ista Zahn , mcg On 2014-11-17 00:23, Nicolas Goaziou wrote: > "Charles C. Berry" writes: >=20 >> For now, I'd be willing to make patches that will allow removal of the >> inline src block results that do *not* involve these header args: [] > IMO, we're too much focused on the implementation details. We ought to > agree on what should be done first. For example, considering > `org-babel-insert-result' and its RESULT-PARAMS argument, I think the > following makes sense: >=20 > | Param | Example output | > |---------+-----------------------------------| > | default | {{{results(42)}}} | > | file | {{{results(file:something.pdf)}}} | > | list | | > | raw | 42 | > | drawer | | > | org | {{{results(src_org{...})}}} | > | html | {{{results(@@html:...@@)}}} | > | latex | {{{results(@@latex:...@@)}}} | > | code | {{{results(src_xxx{...})}}} | >=20 > Basically, it should be possible to remove any kind of result using > "results" macro, with the exception of "raw". "list" and "drawer" can > be ignored since there is no inline equivalent. [] > There's no rush, however. Non-removable results from inline source > blocks have been there for a long time. Hello all, I jump into this conversation because in the next months I will try to write a supplementary information annex using org-mode with Gnu R, so my idea on what should be done follows... I guess I will start my project using those patches. Thanks! A brief review on how how results are presented (or usually anticipated) inline led me to the following wish list: * provide some facilities to keep track of the 'unit of measurement' Few numbers are pure numbers. There is a little value added to the correctness of the work as a whole if I get the correct number from babel but I have hard coded the wrong unit of measure in the text. Please follow the examples. # Load used languages #+BEGIN_SRC emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . nil) (octave . t) (R . t))) #+END_SRC Ideally, I think that reasonable solution would take table like the following: #+TBLNAME:speed-1 | speed | speed_unit | |-------+------------| | 12 | km/s | and output by default or through an easy to call syntax: #+BEGIN_EXAMPLE 12 km/s #+END_EXAMPLE I am not aware of any facilities provided by languages like R or octave to keep track of the unit of measure, If you have some please share. A more space wise representation, that add another layer of indirection would be to have a look-up table like the following: #+TBLNAME:speed-1-units-lookup | name | unit | |--------+------| | speed | km/s | | length | km | | time | s | But I am not sure that it's worth it, at least for those that are working with small data sets. * support for inline rendering of tables The most complex inline output I think I will need at some point follows: #+TBLNAME:data-set-1 #+NAME:data-set-1 | position | item1 | author1 | item2 | author2 | correlation | |----------+-------+---------+-------+---------+-------------| | 1 | i1 | a1 | j1 | b1 | c1 | | 2 | i2 | a2 | j2 | b2 | c2 | | 3 | i3 | a3 | j3 | b3 | c3 | #+NAME: block-1 #+BEGIN_SRC R :session :colnames yes :exports none :var=20 data_set_1=3Ddata-set-1 # Just to show that we use R data_set_2 <- data_set_1 #+END_SRC #+RESULTS: block-1 | position | item1 | author1 | item2 | author2 | correlation | |----------+-------+---------+-------+---------+-------------| | 1 | i1 | a1 | j1 | b1 | c1 | | 2 | i2 | a2 | j2 | b2 | c2 | | 3 | i3 | a3 | j3 | b3 | c3 | And I really like to be easily rendered as an inline string through some formatting specs e.g.: #+BEGIN_EXAMPLE #+PROPERTY: header-args: R :fmt '(%(position)i) =E2=80=9C%(item1)s=E2=80=9D= by=20 /%(author1)s/ correlate to =E2=80=9C%(item2)s=E2=80=9D by /%(author2)s/ = with a=20 correlation coefficient of %(correlation).2f' #+PROPERTY: header-args: R :rowsep (', ', ' and ') The preliminary results show that: src_R[:session :results=20 replace]{data_set_2}. #+END_EXAMPLE Will be rendered as: #+BEGIN_org The preliminary results show that: (1) =E2=80=9Ci1=E2=80=9D by /a1/ correlate to =E2=80=9Cj1=E2=80=9D by /b1= / with a correlation=20 coefficient of c1, (2) =E2=80=9Ci2=E2=80=9D by /a2/ correlate to =E2=80=9Cj2=E2=80=9D by /b2= / with a correlation=20 coefficient of c2 and (3) =E2=80=9Ci3=E2=80=9D by /a3/ correlate to =E2=80=9Cj3=E2=80=9D by /b3= / with a correlation=20 coefficient of c3. #+END_org For languages that does not support tables with headers we can stick with the positional formatting: #+NAME: block-2 #+BEGIN_SRC octave :session :colnames yes :exports none :var=20 data_set_1=3Ddata-set-1 ans =3D data_set_1; #+END_SRC # TODO: figure out why this does not work #+RESULTS: block-2 : iii123aaa123jjj123bbb123ccc123 #+BEGIN_EXAMPLE #+PROPERTY: header-args: octave :fmt '(%i) =E2=80=9C%s=E2=80=9D by /%s/ c= orrelate to=20 =E2=80=9C%s=E2=80=9D by /%s/ with a correlation coefficient of %.2f' #+PROPERTY: header-args: octave :rowsep (', ', ' and ') The preliminary results show that: src_octave[:session :results=20 replace)]{ans}. #+END_EXAMPLE #+BEGIN_org The preliminary results show that: (1) =E2=80=9Ci1=E2=80=9D by /a1/ correlate to =E2=80=9Cj1=E2=80=9D by /b1= / with a correlation=20 coefficient of c1, (2) =E2=80=9Ci2=E2=80=9D by /a2/ correlate to =E2=80=9Cj2=E2=80=9D by /b2= / with a correlation=20 coefficient of c2 and (3) =E2=80=9Ci3=E2=80=9D by /a3/ correlate to =E2=80=9Cj3=E2=80=9D by /b3= / with a correlation=20 coefficient of c3. #+END_org * support for humanization A minor point would be supporting some humanization of the numbers using extended format placeholder to support: - number-as-word or number-as-cardinal :: 1 -> one - number-as-ordinal :: 2 -> second - number-as-pretty-fraction :: 2.3333 -> 2 + 1/3 - number-as-word-fraction :: 2.3333 -> two and one third - number-as-natural-size :: 1000000 -> 1.0 MB - number-as-natural-size-binary :: 1000000 -> 976.6 KiB * auto formatting standard test result It would be nice to simplify the insertion of the result of standard test like Chi-square by taking the =3DR=3D result and rewrite in a sentence form: #+BEGIN_org \Chi-squared =3D 0.214, d.f. =3D 1, p-value < 0.05 #+END_org But this is really lower priority because it will need a lot work to keep track of language and test specific parameters. * Conclusion I really like to hear your feedback on those points. Maybe am I taking the avoidance of cute and paste point of the reproducible research too far? Best, Daniele