Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Dear Bert, Many thanks for your suggestion! I am reading the section to understand more about this topic. It is highly relevant to what I plan to work on. Regards, Shu Fai On Thu, Oct 26, 2023 at 5:38 AM Bert Gunter wrote: > > As you seem to have a need for this sort of capability (e.g.

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Bert Gunter
As you seem to have a need for this sort of capability (e.g. bquote), see Section 6: "Computing on the Language" in the R Language Definition manual. Actually, if you are interested in a concise (albeit dense) overview of the R Language, you might consider going through the whole manual. Cheers,

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Dear Iris, Many many thanks! This is exactly what I need! I have never heard about bquote(). This function will also be useful to me on other occasions. I still have a lot to learn about the R language ... Regards, Shu Fai On Wed, Oct 25, 2023 at 5:24 PM Iris Simmons wrote: > > You can try

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Iris Simmons
You can try either of these: expr <- bquote(lm(.(as.formula(mod)), dat)) lm_out5 <- eval(expr) expr <- call("lm", as.formula(mod), as.symbol("dat")) lm_out6 <- eval(expr) but bquote is usually easier and good enough. On Wed, Oct 25, 2023, 05:10 Shu Fai Cheung wrote: > Hi All, > > I have a

Re: [R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Sorry for a typo, regarding the first attempt, lm_out2, using do.call(), I meant: 'It does have the formula, "as a formula": y ~ x1 + x2. However, the name "dat" is evaluated. ...' Regards, Shu Fai On Wed, Oct 25, 2023 at 5:09 PM Shu Fai Cheung wrote: > > Hi All, > > I have a problem that may

[R] Create a call but evaluate only some elements

2023-10-25 Thread Shu Fai Cheung
Hi All, I have a problem that may have a simple solution, but I am not familiar with creating calls manually. This is example calling lm() ``` r set.seed(1234) n <- 10 dat <- data.frame(x1 = rnorm(n), x2 = rnorm(n), y = rnorm(n)) lm_out <- lm(y ~ x1 + x2,