( I just became aware the mailer enforces html bodies, as such removed
by the list handler. Sorry about that. My message was )
I have this function
slm <- function(fun=lm, ...) {
#ilm <- eval(match.call()[-1]); # no way
ilm <- eval(parse(text=sub("^list", deparse(substitute(fun)),
deparse(substitute(...())))));
...
The latter actually does the trick, but recognising how some gurus hate
parse, I would like to know if this can anyhow be done with match.call,
or any other reasonable solution.
The issue here is that lm (and likewise glm, bayesglm, etc.) returns the
function call, which needs to show up as the original args to slm of course.
~~harald e
putting match.call to good use
5 messages · Harald Eikrem, Brian Ripley, Peter Dalgaard +1 more
On Wed, 28 Jan 2009, Harald Eikrem wrote:
( I just became aware the mailer enforces html bodies, as such removed by the
list handler. Sorry about that. My message was )
I have this function
slm <- function(fun=lm, ...) {
#ilm <- eval(match.call()[-1]); # no way
ilm <- eval(parse(text=sub("^list", deparse(substitute(fun)),
deparse(substitute(...())))));
...
The latter actually does the trick, but recognising how some gurus hate
parse, I would like to know if this can anyhow be done with match.call, or
any other reasonable solution.
The issue here is that lm (and likewise glm, bayesglm, etc.) returns the
function call, which needs to show up as the original args to slm of course.
The way to do this is eval(substitute()). E.g. from the new Rd2HTML
Rd <- eval(substitute(parse_Rd(f, encoding = enc),
list(f = Rd,enc = encoding)))
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Prof Brian Ripley wrote:
On Wed, 28 Jan 2009, Harald Eikrem wrote:
( I just became aware the mailer enforces html bodies, as such removed
by the list handler. Sorry about that. My message was )
I have this function
slm <- function(fun=lm, ...) {
#ilm <- eval(match.call()[-1]); # no way
ilm <- eval(parse(text=sub("^list", deparse(substitute(fun)),
deparse(substitute(...())))));
...
The latter actually does the trick, but recognising how some gurus
hate parse, I would like to know if this can anyhow be done with
match.call, or any other reasonable solution.
The issue here is that lm (and likewise glm, bayesglm, etc.) returns
the function call, which needs to show up as the original args to slm
of course.
The way to do this is eval(substitute()). E.g. from the new Rd2HTML
Rd <- eval(substitute(parse_Rd(f, encoding = enc),
list(f = Rd,enc = encoding)))
I don't understand the substitute(...()) bit (looks like an unexpected feature), but I suspect that it might also be a good idea to read and understand the first dozen lines or so of the lm function itself.
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes:
The way to do this is eval(substitute()). E.g. from the new Rd2HTML
What is Rd2HTML? Dieter
On Wed, 28 Jan 2009, Dieter Menne wrote:
Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes:
The way to do this is eval(substitute()). E.g. from the new Rd2HTML
What is Rd2HTML?
A function in the R-devel version of R (is 'new' not rather a hint?).
From the NEWS file:
o parse_Rd(), an experimental parser for Rd files, and Rd2txt(), Rd2HTML(), Rd2latex() and Rd2ex(), even more experimental converters, have been added to package 'tools'.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595