From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: [PATCH] -for review- Tangling with variable transfer of variables Date: Fri, 20 Jun 2014 15:15:31 +0200 Message-ID: References: <87zjh8bo8s.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]:53746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxyfU-0005xK-69 for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 09:15:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxyfO-0007si-6q for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 09:15:48 -0400 Received: from mail-we0-f175.google.com ([74.125.82.175]:34052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxyfN-0007sa-TA for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 09:15:42 -0400 Received: by mail-we0-f175.google.com with SMTP id k48so3813198wev.34 for ; Fri, 20 Jun 2014 06:15:38 -0700 (PDT) In-Reply-To: (Charles Berry's message of "Thu, 19 Jun 2014 23:23:56 +0000 (UTC)") 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 Berry Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Charles Berry writes: > Aaron Ecay gmail.com> writes: > >>=20 >> Hi Rainer, >>=20 >> I have not tested the patch (I rarely use :var), but here are some >> comments from reading the patch. >>=20 > [snip] >>=20 >> > (header (if (or (eq (nth 1 value) 'hline) colnames-p) >> > "TRUE" "FALSE")) >> > (row-names (if rownames-p "1" "NULL"))) >> > (if (=3D max min) >> > - (format "%s <- read.table(\"%s\", >> > + (format "%s <- read.table(textConnection('%s'), >>=20 >> This will fail if =E2=80=98file=E2=80=99 contains an apostrophe characte= r. I guess you >> need to escape apostrophes in =E2=80=98file=E2=80=99. >>=20 > > There are a bunch of issues with the textConnection - the point Aaron > makes, the nasty name (try showConnections() to see), and close()-ing it. > > I think you need something more like this: > > =3D=3D=3D=3D > (header (if (or (eq (nth 1 value) 'hline) colnames-p) > "TRUE" "FALSE")) > (row-names (if rownames-p "1" "NULL"))) > (if (=3D max min) > (format " > %s <-=20 > local({con.object <-=20 > %S > con <- textConnection(con.object) > res <- read.table(con, > header=3D%s, > row.names=3D%s, > sep=3D\"\\t\", > as.is=3DTRUE) > close(con) > res})"=20 > name file header row-names) > > =3D=3D=3D=3D > > Notes: %S handles Aaron's quoting issue. > local() keeps unwanted objects out of user's way. > This worked on a couple of simple tests I agree completely here - thanks for the %S (didn't know about it - now I do) and haven't thought about the local() - I think it is a very good idea to use it in the context of the variable transfer. > > If you have `:session :results output' headers your session > transcript will have `file' dumped into it, which might be an annoyance. Not only annoyance - can cause overwriting of the data. Will look into this. Thanks a lot, Rainer > > HTH, > > Chuck > > > > =2D-=20 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,= UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJTpDPzAAoJENvXNx4PUvmCAzUH+QFJtcpQ3SJN8awqm95WXaWi +3XLIOIBek8dcII/wPRq289mALGsB6ak3iI1RN+f/nfSBb+UEP3oPk2elzbomGfa f+94but2rdi8v7GD9f4v4sF7qhvKeF7bBLbqOiQtl/MoyoDKR0la1QCDP19qytiT y/OF+xzUFLf/E5bclt8G/3tQ3vCv1NSDnjC5gOCL9WrD0pJ6hNLvYIlwFGh5lHSP Vr4NmD0iDvxyn6+o5z4PcYJ0Vkx+2+DVNu8wq5qI+2m/SVU8JL9vLwnYu7eEnj9S bn/WQ+R/UKRBpSr17e0fWSDNyxNjFA1naNGGhft115G2FTlN1ubXMSo0xUfAumU= =GFPZ -----END PGP SIGNATURE----- --=-=-=--