From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: [babel, bug?] colnames with a list of columns does not work Date: Fri, 23 Jan 2015 11:35:29 +0100 Message-ID: <86d265pyxa.fsf@example.com> References: <86zj9bytg4.fsf@example.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hello Thomas and Rainer, Rainer M Krug wrote: > Sebastien Vauban writes: >> >> #+begin_src R :rownames yes :colnames '(Lg Nb) >> data(iris) >> head(table(iris$Petal.Length, iris$Species)[, "setosa"], n=3D2) >> #+end_src >> >> returns: >> >> | | x | >> |-----+----| >> | 1 | 1 | >> | 1.1 | 1 | >> >> while I was expecting: >> >> | Lg | Nb | >> |-----+----| >> | 1 | 1 | >> | 1.1 | 1 | > > WHy should it? The org-info manual states: > > ,---- > | The `:colnames' header argument accepts the values `yes', `no', or > | `nil' for unassigned. The default value is `nil'. Note that the > | behavior of the `:colnames' header argument may differ across > | languages.=20 > `---- > > It says nothing about accepting any other values. > Unless I am missing something? Yes, you just show that the documentation is not up-to-date, as that functionality *is* implemented for most languages. Doing some bit of archeology, I just found out that: - Eric wrote a patch to support the above (but it hasn't be applied), - I (!) even wrote a test of that functionality (for a shell block) in `testing/lisp/test-ob.el'. See https://lists.gnu.org/archive/html/emacs-orgmode/2013-04/msg00527.html: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 It looks like ob-R implements its own result table reconstructi= on =E2=94=82 instead of using the general support. This is because R actual= ly =E2=94=82 has a notion of column names and row names internally. The =E2=94=82 implementation in ob-R does not correctly handle specified coln= ames =E2=94=82 as your example shows. =E2=94=82=20 =E2=94=82 The attached patch brings ob-R closer to the using the unified =E2=94=82 general table reconstructed used in most other languages, and f= ixes =E2=94=82 your problem mentioned above. I haven't applied it however, as= it =E2=94=82 may introduce other bugs related to specifying column names from =E2=94=82 within R. For example, I'm not sure that it will now correctly =E2=94=82 apply column names from a table built entirely from within R. =E2=94=82=20 =E2=94=82 Additional testing by someone more familiar with R than myself = would =E2=94=82 be greatly appreciated. =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 Should such someone (more familiar with R) be able to confirm that his patch work without introducing problems, it could be applied so that R should behave the same as in most languages... Best regards, Seb --=20 Sebastien Vauban