In addition to what has already been suggested, you can use debug (and
subsequently undebug) to browse a function step by step to see what each
step of the function is doing.
For your specific query about match.call(), I suspect that your
'puzzlement' is that you don't know what a function call is
I think the tricky part here is the different types of `quote`. I
would use `bquote` here, try:
doit <- function(x){
ds <- deparse(substitute(x))
cat("1\n")
print(ds)
eval(bquote(lm(.(ds))),parent.frame())
}
Just note that getting the parent.frame() portion right in anything
more complic
В Thu, 16 Mar 2023 14:53:33 +
"Sorkin, John" пишет:
> I am trying to run the lm function on two different formulae:
> 1) y~x,
> 2) y~x+z
A formula is already an unevaluated object that doesn't need further
quoting; thus it can be passed around like a normal variable. It
consists of a call t
G'day John,
For these snippets to produce what I think you want them to produce it
is just necessary to define doit() as follows:
doit <- function(x){
lm(formula=x)
}
R> # run formula y~x
R> JD <- doit(y~x)
R> JD
Call:
lm(formula = x)
Coefficients:
(Intercept)x
0.8403
The first thing to understand is that despite similarity in names,
`match` and `match.call` are doing very different things, which should
not be confused with each other.
For understanding what a function is doing, it is helpful to watch
what it does at each step. With functions like `lm` that ar
Although I owe thanks to Ramus and Ivan, I still do not know how to write and
"advanced" function.
My most recent try (after looking at the material Ramus and Ivan set) still
does not work. I am trying to run the lm function on two different formulae:
1) y~x,
2) y~x+z
Any corrections would be
On 2023-03-16 12:11 +, Sorkin, John wrote:
> (1) can someone point me to an
> explanation of match.call or match
> that can be understood by the
> uninitiated?
Dear John,
the man page ?match tells us that match
matches the first vector against the
second, and returns a vector of indecie
В Thu, 16 Mar 2023 12:11:35 +
"Sorkin, John" пишет:
> (1) can someone point me to an explanation of match.call or match
> that can be understood by the uninitiated? (2) can someone point me
> to a document that will help me learn how to write an "advanced"
> function?
By "advanced" functions
I am trying to understand how to write an "advanced" function. To do so, I am
examining the lm fucnction, a portion of which is pasted below. I am unable to
understand what match.call or match does, and several other parts of lm, even
when I read the help page for match.call or match.
(1) can
I am trying to understand how to write an "advanced" function. To do this, I am
examining the code of lm, a small part of the lm code is below. N
> lm
function (formula, data, subset, weights, na.action, method = "qr",
model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
c
10 matches
Mail list logo