[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 22:34:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) |
Attached please find =the reworked patch.
1) uses local() and closes connection
2) does not leave a variable cal;led file behind
Cheers,
Rainer
0001-lisp-ob-R.el-Fix-tangling-with-tables.patch
Description: The Patch
Rainer M Krug <address@hidden> writes:
> 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
pgpS5VbUulQol.pgp
Description: PGP signature
- [O] [PATCH] -for review- Tangling with variable transfer of variables, Rainer M Krug, 2014/06/19
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Aaron Ecay, 2014/06/19
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Charles Berry, 2014/06/19
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Rainer M Krug, 2014/06/23
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Rainer M Krug, 2014/06/23
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Charles C. Berry, 2014/06/23
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Rainer M Krug, 2014/06/24
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Rainer M Krug, 2014/06/23
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Charles C. Berry, 2014/06/23
- Re: [O] [PATCH] -for review- Tangling with variable transfer of variables, Rainer M Krug, 2014/06/24