-project.org; Sorkin, John
Subject: Re: [R] Trying to understand the magic of lm (Still trying)
John,
The text below is cut out of a "how to write a package" course I gave at the R
conference in Vanderbilt. I need to find a home for the course notes, because
it had a lot of tidbits that ar
John,
The text below is cut out of a "how to write a package" course I gave at the
R
conference in Vanderbilt. I need to find a home for the course notes, because
it had a
lot of tidbits that are not well explained in the R documentation.
Terry T.
Model frames:
One of the first task
On 5/10/19 12:53 PM, Sorkin, John wrote:
A number of people have helped me in my mission to understand how lm (and other
fucntions) are able to pass a dataframe and then refer to a specific column in
the dataframe. I thank everyone who has responded. I now know a bit about
deparse(substitute
A number of people have helped me in my mission to understand how lm (and other
fucntions) are able to pass a dataframe and then refer to a specific column in
the dataframe. I thank everyone who has responded. I now know a bit about
deparse(substitute(xx)), but I still don't fully understand how
I don't think previous responses have addressed the question, which appears
to be: "How does R know to look in the "data" object for the variable names
in the formula?" And, of course, I could be wrong -- in which case ignore
all the following.
My answer to that question is: it's quite complicated
Hello John,
Others have commented on the first half of your question, but the
second half of your question looks very much like R's built-in
predict() functions:
>?predict
>?predict.lm
Best Regards,
Bill.
W. Michels, Ph.D.
On Wed, May 8, 2019 at 6:23 PM Sorkin, John wrote:
>
> Can someone
Hello,
There is a "standard" deparse/substitute trick that gets the names of
the variables passed to a function. There are more sophisticated ways
but maybe that is what you are looking for.
myfunction <- function(y, x, dataframe){
y <- deparse(substitute(y))
x <- deparse(substitute(x))
Hi,
I'm not sure if this is what you are after, but instead of defining arguments
for elements of the formula why not simply pass your desired formula to your
function?
Cheers,
Ben
myfunction <- function(frmla,dataframe){
fit0 <- lm(frmla,data=dataframe)
print (summary(fit0))
}
# Run the
Can someone send me something I can read about passing parameters so I can
understand how lm manages to have a dataframe passed to it, and use columns
from the dataframe to set up a regression. I have looked at the code for lm and
don't understand what I am reading. What I want to do is somethin
9 matches
Mail list logo