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: Charles Berry
Subject: Re: [O] [PATCH] -for review- Tangling with variable transfer of variables
Date: Thu, 19 Jun 2014 23:23:56 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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

If you have `:session :results output' headers your session
transcript will have `file' dumped into it, which might be an annoyance.

HTH,

Chuck






reply via email to

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