Le mardi 24 janvier 2012 à 23:02 -0800, moli a écrit : > I want use survfit() and basehaz() inside a function, but it doesn't work. > Could you take a look at this problem. Thanks for your help. Following is my > codes: <snip>
> Error in formula.default(object, env = baseenv()) : invalid formula > > > But the following function works: > coxph(fmla, phmmd) Please provide us with a shorter code to reproduce the problem. You can't expect people to read debug the whole function to identify the problem. You can use traceback() after the error occurs to see where it comes from. Also, reproducing the code here doesn't lead to the same error: Error in model.frame(formula = x, data = phmmd) : object 'x' not found Cheers ______________________________________________ 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.