emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] -for review- Tangling with variable transfer of variable


From: Rainer M Krug
Subject: Re: [O] [PATCH] -for review- Tangling with variable transfer of variables
Date: Fri, 20 Jun 2014 15:15:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin)

Charles Berry <address@hidden> writes:

> Aaron Ecay <aaronecay <at> gmail.com> writes:
>
>> 
>> Hi Rainer,
>> 
>> I have not tested the patch (I rarely use :var), but here are some
>> comments from reading the patch.
>> 
> [snip]
>> 
>> >          (header (if (or (eq (nth 1 value) 'hline) colnames-p)
>> >                      "TRUE" "FALSE"))
>> >          (row-names (if rownames-p "1" "NULL")))
>> >      (if (= max min)
>> > -        (format "%s <- read.table(\"%s\",
>> > +        (format "%s <- read.table(textConnection('%s'),
>> 
>> This will fail if ‘file’ contains an apostrophe character.  I guess you
>> need to escape apostrophes in ‘file’.
>> 
>
> 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:
>
> ====
>                  (header (if (or (eq (nth 1 value) 'hline) colnames-p)
>                               "TRUE" "FALSE"))
>                   (row-names (if rownames-p "1" "NULL")))
>               (if (= max min)
>                   (format "
>     %s <- 
>         local({con.object <- 
>     %S
>     con <- textConnection(con.object)
>     res <- read.table(con,
>                       header=%s,
>                       row.names=%s,
>                       sep=\"\\t\",
>                       as.is=TRUE)
>     close(con)
>     res})" 
>                   name file header row-names)
>
> ====
>
> 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
>
>
>
>

-- 
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:      address@hidden

Skype:      RMkrug

PGP: 0x0F52F982

Attachment: pgpbXP7E5USUm.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]