Re: [R] formula error inside function

2012-02-02 Thread Hugh Morgan
Hi, I have fixed this. I replaced the "=" with "<<-". I do not think this is the most elegant way, so if anyone else has any better ideas they would be very much apperitiaded. New lines: formulaGenotype <<- test_variable~Genotype + Gender formulaNull <<- test_variable~Gender Cheers,

Re: [R] formula error inside function

2012-01-29 Thread Hugh Morgan
Hi, I have what I suppose is the same problem as this. I am using the linear mixed model function lme, and this does not seems to take the attribute "model=TRUE" at the end of the function. Is there a more general way of solving this problem? Is my description of the problem below correct (f

Re: [R] formula error inside function

2012-01-25 Thread moli
Thanks for you help. I also spent a lot of time on it. Your explanation is very clear. -- View this message in context: http://r.789695.n4.nabble.com/formula-error-inside-function-tp4326549p4328117.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] formula error inside function

2012-01-25 Thread David Winsemius
On Jan 25, 2012, at 2:02 AM, moli wrote: 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: library(survival) n <- 50 # total sample size nclust <- 5 # number of clusters clust

Re: [R] formula error inside function

2012-01-25 Thread Terry Therneau
> 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. Your problem has to do with environments, and these lines fmla <- as.formula("Surv(time, event) ~ Z1 + Z2") BaseFun <- function(x){ start.coxp

Re: [R] formula error inside function

2012-01-25 Thread Milan Bouchet-Valat
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: > Error in formula.default(object, env = baseenv()) : invalid formula > >

[R] formula error inside function

2012-01-25 Thread moli
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: library(survival) n <- 50 # total sample size nclust <- 5 # number of clusters clusters <- rep(1:nclust,each=n/nclust) beta0 <- c(1,