Rainer M Krug writes: > Charles Berry writes: > >> Aaron Ecay 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: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982