From mboxrd@z Thu Jan 1 00:00:00 1970 From: Titus von der Malsburg Subject: Re: Bug: Org export to latex produces incorrect table [8.3beta (release_8.3beta-1157-g8ddb84 @ /home/malsburg/usr/share/emacs/site-lisp/org/)] Date: Fri, 29 May 2015 11:54:21 -0700 Message-ID: <87y4k7i59e.fsf@posteo.de> References: <87y4kefvo9.fsf@posteo.de> <87wpzyfn46.fsf@posteo.de> <87vbfieywt.fsf@posteo.de> <87twv1g8ao.fsf@posteo.de> <87r3pz2084.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyPQV-0002LP-1N for emacs-orgmode@gnu.org; Fri, 29 May 2015 14:54:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyPQP-0006VQ-Pf for emacs-orgmode@gnu.org; Fri, 29 May 2015 14:54:38 -0400 Received: from mx02.posteo.de ([89.146.194.165]:46343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyPQP-0006Ux-GK for emacs-orgmode@gnu.org; Fri, 29 May 2015 14:54:33 -0400 In-reply-to: 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" Cc: emacs-orgmode@gnu.org, "Thomas S. Dye" , Nicolas Goaziou --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2015-05-29 Fri 11:09, Charles C. Berry wrote: > On Fri, 29 May 2015, Nicolas Goaziou wrote: > >> Titus von der Malsburg writes: >> >>> On 2015-05-24 Sun 10:09, Thomas S. Dye wrote: >>>> Titus von der Malsburg writes: >>>> >>>>> On 2015-05-24 Sun 08:36, Thomas S. Dye wrote: >>>>>> Titus von der Malsburg writes: >>>>>> >>>>>>>> You got the result of rownames(x), which is expected. The table y= ou >>>>>>>> expect is given by the following code: >>>>>>> >>>>>>> Ah, I see, thanks. Although the results is still somewhat >>>>>>> unexpected. c("One:", "Two:") doesn=E2=80=99t have rownames and co= lnames. So >>>>>>> org apparently made them up when generating the table. >>>>>> >>>>>> Also expected due to :rownames yes :colnames yes. Without those two >>>>>> header arguments: >>>>>> >>>>> >>>>> Consider this example: >>>>> >>>>> #+BEGIN_SRC R :results table :exports results :colnames yes :rownames= yes >>>>> v <- c("a", "b") >>>>> #+END_SRC >>>>> >>>>> #+RESULTS: >>>>> | | x | >>>>> |---+---| >>>>> | 1 | a | >>>>> | 2 | b | >>>>> >>>>> Where is the =E2=80=9Cx=E2=80=9D coming from? In R, colnames(v) give= s me NULL. >>>> >>>> rownames(v) is also NULL. >>>> >>>> You are asking Org mode to produce a table with row and column names >>>> from a vector, which lacks rows and columns. What behavior do you >>>> expect? >>> >>> Almost anything is better than Org showing me values that do not exist >>> in the original data. Empty cells for row and columns names are >>> probably the best solution because that would be faithful to the data >>> and to the settings (:rownames yes :colnames yes). >> >> AFAICT, the "x" comes from R, not Org. It could also come from the way >> Org calls R, but I don't know enough of the latter to tell. >> > > In particular, `org-babel-R-write-object-command' contains an R > function that processes the object for `:results value'. The guts of > it is a call to write.table(). Here is an example: > > > #+NAME: show write.table > #+BEGIN_SRC R :results output > write.table(c("a","b")) > #+END_SRC > > #+RESULTS: show write.table > : "x" > : "1" "a" > : "2" "b" > > The difficulty is that write.table() coerces its first argument to a=20 > `data.frame', whence the odd seeming row/column labels. > > Making the R code in `org-babel-R-write-object-command' smart enough > to do what the OP wants without breaking stuff might be possible if=20 > anyone wants to do the work. Thanks for the pointer, Charles. If this is standard behaviour in R, I=E2=80=99m actually fine with it. It just wasn=E2=80=99t clear that write= .table is used for making tables. I would add a note about this in the documentation but, correct me if I=E2=80=99m wrong, the whole =E2=80=9C:results table=E2=80=9C-thing i= sn=E2=80=99t yet described in the documentation. Is that correct? Titus > However, IMO `:results output' is the way to go for such cases. There are= =20 > plenty of tools in R for formatting output and the user will have better= =20 > control over what is produced. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVaLXdAAoJEK40WfPGE2idRsYH+gIENteGfowV7u9giaLcYKAp DfEjKzSr6n6H6u7FXEs8n5xsgm49OE4v2aAmhPMhr8PTMvHGEJgUwvisp/uI2+WX U6uWkwKs6tbz2vYePjDYssB/H1DLz1CZUvOSB5TIBJhewK8E7vwk6l5W9d2OKVpn qGigVVSXBb8mhXKt6xmENyvkSxpVtcqecA8/WD4xuuVaycXYabfBccWeEeE7gAuH v/oilfsFQpeJFpBAXFmVRfeHRlttntathdgGmnTWhTBL23JUbYS/CENpOwgDrHe2 rpAyOktiDpLhFV7SACofNLbEbvnJhX7k2ve2HN26frrFQotI7Rttk/dcdM9A7Fw= =/7KU -----END PGP SIGNATURE----- --=-=-=--