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] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run

2023-10-25 Thread Duncan Murdoch
Actually a better solution would be to make PID into a factor. They can always be coerced to a number, but will display with your meaningful labels. Duncan Murdoch On 25/10/2023 3:38 p.m., Duncan Murdoch wrote: I don't see it documented, but it appears that the gee() function assumes the id

Re: [R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run

2023-10-25 Thread Duncan Murdoch
I don't see it documented, but it appears that the gee() function assumes the id variable can be coerced to a number. Your ids are in PID, and are strings like "HIPS004", etc. Change that to "004" or a numeric 4 and the error goes away. Duncan Murdoch On 25/10/2023 3:23 p.m., Sorkin, John

[R] Error running gee function. I neither understand the error message, nor know what needs to be done the get the gee to run

2023-10-25 Thread Sorkin, John
Colleagues, I am receiving several error messages from the gee function. I don't understand the ides the error messages are trying to impart, and I don't know how to debug or correct the error. The error messages follow: > fitgee <- gee(HipFlex ~ >

Re: [R] by function does not separate output from function with mulliple parts

2023-10-25 Thread Rui Barradas
Às 00:22 de 25/10/2023, Sorkin, John escreveu: Colleagues, I have written an R function (see fully annotated code below), with which I want to process a dataframe within levels of the variable StepType. My program works, it processes the data within levels of StepType, but the usual headers

Re: [R] by function does not separate output from function with, mulliple parts

2023-10-25 Thread Leonard Mada via R-help
Dear John, Printing inside the function is problematic. Your function itself does NOT print the labels. Just as a clarification: F = factor(rep(1:2, 2)) by(data.frame(V = 1:4, F = F), F, function(x) { print(x); return(NULL); } ) #   V F # 1 1 1 # 3 3 1 #   V F # 2 2 2 # 4 4 2 # F: 1 <- this

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,