Hi, I would like to write a function which has the following syntax:
myfn <- function(formula, ftime, fstatus, data) { # step 1: obtain terms in `formula' from dataframe `data' # step 2: obtain ftime from `data' # step 3: obtain fstatus from `data' # step 4: do model estimation # step 5: return results } The user would call this function as: myfn(formula=myform, ftime=myftime, fstatus=myfstatus, data=mydata) Where `myform' is a formula object; and the terms in `myform', and the variables `myftime' and `myfstatus' should be obtained from the dataframe `mydata'. I am getting tripped up in trying to figure out how to do the seemingly simple steps of 1, 2, and 3. I looked at the code for `lm', `coxph', `nls' etc, but they are too complicated for my understanding. Is there a simple way to accomplish this? Thanks very much, Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.