emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rainer M Krug <Rainer@krugs.de>
To: "Charles C. Berry" <ccberry@ucsd.edu>
Cc: emacs-orgmode@gnu.org, Eric Schulte <schulte.eric@gmail.com>
Subject: Re: [PATCH] -for review- Tangling with variable transfer of variables
Date: Mon, 23 Jun 2014 10:57:48 +0200	[thread overview]
Message-ID: <m2mwd4ngtv.fsf@krugs.de> (raw)
In-Reply-To: <alpine.OSX.2.00.1406211148460.344@charles-berrys-macbook.local> (Charles C. Berry's message of "Sat, 21 Jun 2014 12:44:01 -0700")

[-- Attachment #1: Type: text/plain, Size: 2284 bytes --]

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> On Fri, 20 Jun 2014, Rainer M Krug wrote:
>
>> Attached please find =the 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 
> :var value when it is echoed in the session log so it will be easier to 
> view.

Done

>
> ===
>
> 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=undant, as the function format is doing it
anyway?

I'll leave the second line out and replace it with =value= 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 
> allows almost anything to be passed to R as a string.
>
> So
>  	:var x=[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 = X\beta,
>      \mbox{where } \beta = %beta%
>    \end{math}
> #+END_SRC
>
> #+BEGIN_SRC R :var ytxt=latex-capt :results raw :wrap latex
> beta <- 1.234
> sub("%beta%",beta,ytxt)
> #+END_SRC
>
>
> HTH,
>
> Chuck

-- 
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

[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]

  parent reply	other threads:[~2014-06-23  8:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 20:19 [PATCH] -for review- Tangling with variable transfer of variables Rainer M Krug
2014-06-19 21:09 ` Aaron Ecay
2014-06-19 23:23   ` Charles Berry
2014-06-20 13:15     ` Rainer M Krug
2014-06-20 20:34       ` Rainer M Krug
2014-06-21 19:44         ` Charles C. Berry
2014-06-22  3:39           ` Aaron Ecay
2014-06-23 10:46             ` Rainer M Krug
2014-06-23  8:57           ` Rainer M Krug [this message]
2014-06-23  9:14           ` Rainer M Krug
2014-06-23 17:56             ` Charles C. Berry
2014-06-24 12:08               ` Rainer M Krug
2014-06-23 10:45           ` Rainer M Krug
2014-06-23 18:25             ` Charles C. Berry
2014-06-24 12:28               ` Rainer M Krug
2014-06-20 13:07   ` Rainer M Krug

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2mwd4ngtv.fsf@krugs.de \
    --to=rainer@krugs.de \
    --cc=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).