From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: org tables into R? Date: Wed, 07 Jan 2015 10:01:43 +0100 Message-ID: References: <874ms6w0it.fsf@gmail.com> <87zj9xa1ni.fsf@nicolasgoaziou.fr> <87lhlfvly2.fsf@gmail.com> 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]:42922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8re2-0004PL-Rn for emacs-orgmode@gnu.org; Wed, 07 Jan 2015 09:31:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8rdx-0004p5-4J for emacs-orgmode@gnu.org; Wed, 07 Jan 2015 09:31:34 -0500 Received: from mail-wg0-f50.google.com ([74.125.82.50]:50012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8rdw-0004ob-SO for emacs-orgmode@gnu.org; Wed, 07 Jan 2015 09:31:29 -0500 Received: by mail-wg0-f50.google.com with SMTP id a1so1271639wgh.23 for ; Wed, 07 Jan 2015 06:31:28 -0800 (PST) In-Reply-To: <87lhlfvly2.fsf@gmail.com> (Aaron Ecay's message of "Tue, 06 Jan 2015 12:49:25 -0500") 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: Andreas Leha Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Aaron Ecay writes: > Hi Rainer and Andreas, > > 2015ko urtarrilak 6an, Rainer M Krug-ek idatzi zuen: >> What would definitely solve the issue is if the string containing the >> tabs would use \t instead - but I have no idea how this could be >> achieved easily. > > This could be achieved by modifying the call to orgtbl-to-csv in > org-babel-R-assign-elisp: > > diff --git i/lisp/ob-R.el w/lisp/ob-R.el > index 6f76aa5..ec3f110 100644 > --- i/lisp/ob-R.el > +++ w/lisp/ob-R.el > @@ -239,7 +239,10 @@ This function is called by `org-babel-execute-src-bl= ock'." > (min (if lengths (apply 'min lengths) 0))) > ;; Ensure VALUE has an orgtbl structure (depth of at least 2). > (unless (listp (car value)) (setq value (list value))) > - (let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-fie= ld))) > + (let ((file (replace-regexp-in-string > + "\t" "\\t" > + (orgtbl-to-tsv value '(:raw t :fmt org-babel-R-quote= -tsv-field)) > + nil t)) > (header (if (or (eq (nth 1 value) 'hline) colnames-p) > "TRUE" "FALSE")) > (row-names (if rownames-p "1" "NULL"))) > > (This is just a quick hack; if it works then the code should actually > use orgtbl-to-generic to do the conversion in a single step.) That looks like it would work.=20 > >> ,---- >> | ...=20=20 >> | sep =3D \"\", ;;;;;<<<<<<<<< was before sep =3D \"\\t\" >> | ... >> `---- >>=20 >> This will set the separator to "whitespace", i.e. "that is one or more >> spaces, tabs, newlines or carriage returns" (from R help). > > This was the approach that Michael took in his original patch. It > introduces new bugs related to the handling of quotes, though =E2=80=93 s= ee the > =E2=80=9CDetails=E2=80=9D section of ?scan in R for the gory details (beg= inning with =E2=80=9CIf > =E2=80=98sep=E2=80=99 is the default=E2=80=9D...). I agree completely - it would not be a final solution but possibly solve the problem temporarily in an emacs.org file. But the real question is: why are on some setups the tabs converted to spaces? > > Andreas raised a bug a while ago that indicates to me that this code > should switch to csv rather than a whitespace-delimited format. But > there are lots of corner cases, and I have not had time to work on a > patch that I am confident could cover them all. Might be a solution - but I do not know how commas are working under different locales. In MS Office, a csv file is a semicolon (;) separated file when in the chosen language settings a comma is used as decimal separator - and and I have no idea if language settings affect emacs in the same way (I actually don't hope so). This makes me think - why not use "|" as a separator (as it is the case in org)? In this way, all tables which are in org can be directly given to R as strings without the hassle of to much of conversion? Rainer > > Andreas=E2=80=99s original report (also referenced earlier in this thread= ): > http://news.gmane.org/find-root.php?message_id=3Dolulhmmtei5.fsf%40med.un= i%2dgoettingen.de > > Thanks, =2D-=20 Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJUrPX7AAoJENvXNx4PUvmCXJoH/iSF8L16HMpvU8rAsTwDKxol 6DWvhA5AIJeeYAKq2+8VGbFtEFHQDjpQf2Gm122F8+2j0TfjLFxGpdYAF+ss25Cn O0S7x3SAeCZMmVjYCEDvI/IsD5Qqze0TyO/0XnuggkhBfpH9COKVallpjSWZQMLY mJPTJKIciBTm6nyYKjbvlseP3uo2kcFs6c8kAmzHISfAgtGewJZnwLzvi7YFDDXz f2dmorTQCUO4qh5G7uVD9n6ohywCzYOWBIsy4chX/D4bcdxUQoiKOJhBh8dwaZw1 ELEV+qRa3qI4ZKY8QuncsXepSmsuOTYJULgrz4fxnhAJ9ZOcuZVXBraySRbgYoY= =dPHQ -----END PGP SIGNATURE----- --=-=-=--