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: Mon, 23 Jun 2014 10:57:48 +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]:50794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz04i-0001Ci-C8 for emacs-orgmode@gnu.org; Mon, 23 Jun 2014 04:58:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz04c-0000Dv-DU for emacs-orgmode@gnu.org; Mon, 23 Jun 2014 04:58:04 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:45264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz04c-0000Dg-7G for emacs-orgmode@gnu.org; Mon, 23 Jun 2014 04:57:58 -0400 Received: by mail-we0-f174.google.com with SMTP id u57so6455222wes.5 for ; Mon, 23 Jun 2014 01:57:57 -0700 (PDT) In-Reply-To: (Charles C. Berry's message of "Sat, 21 Jun 2014 12:44:01 -0700") 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, Eric Schulte --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable "Charles C. Berry" writes: > On Fri, 20 Jun 2014, Rainer M Krug wrote: > >> Attached please find =3Dthe reworked patch. >> >> 1) uses local() and closes connection >> 2) does not leave a variable cal;led file behind >> > > Seems to work on a few test cases. > > I'd move the strings to defconsts. > > Putting a newline before each `%S' will outdent the first line of=20 > :var value when it is echoed in the session log so it will be easier to=20 > view. Done > > =3D=3D=3D > > With Eric's input on this: > > Would you also change this at the end of org-babel-R-assign-elisp: > > res})" name file header row-names max)))) > - (format "%s <- %s" name (org-babel-R-quote-tsv-field value)))) > + (format "%s <- %S" name > + (if (stringp value) value (prin1-to-string value))))) > Good idea - done. but as far as I understand the help for the function format %S ,---- | %S means print any object as an s-expression (using `prin1'). `---- the second line is redy=3Dundant, as the function format is doing it anyway? I'll leave the second line out and replace it with =3Dvalue=3D instead, but please correct meif I am missing something here. Thanks, Rainer > ?? > > I think this is innocuous for plain strings with no internal quotes, but= =20 > allows almost anything to be passed to R as a string. > > So > :var x=3D[1 2 3 "4" 5] > > will be passed to R as x <- "[1 2 3 \"4\" 5]" > > instead of x <- "[1 2 3 "4" 5] which throws an error. > > And this just works: > > #+NAME: latex-capt > #+BEGIN_SRC latex > \begin{math} > y =3D X\beta, > \mbox{where } \beta =3D %beta% > \end{math} > #+END_SRC > > #+BEGIN_SRC R :var ytxt=3Dlatex-capt :results raw :wrap latex > beta <- 1.234 > sub("%beta%",beta,ytxt) > #+END_SRC > > > 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) iQEcBAEBAgAGBQJTp+wQAAoJENvXNx4PUvmCHQEIAJufeKx2syfLUpJMxX4bF8Z5 NrhMhh+rFaG0ykXNEZtquMM8iGhCu6ZJbM1jDYHhTGq9bcVFjQdw41nAsWQ5up/w ubVeS46l9hS8JZR+V+DcdHxqqQcj6Zty82Y/nmtTujsa/77sMY88eDHDjj2PUzrr fYKdS8CF+dniqVA2dNPikDz3EkP4YvH1Dx6UY6BkvFllQ6WSI4+bQ2+XgmfuQeAb FUZvLljJkrcmMSKomMfP6p4D3fb1c5CuMYBO1btDT1EuxGR3SGf/o29eQCoh/5Xq SW44BLSmcW1ze3PONfCO0cncTKwOniV3ElVQqoPFyJ7aCG20AsqhZQvh4WGuR+M= =F2CL -----END PGP SIGNATURE----- --=-=-=--