Re: [R] writing simple function through script

2008-09-11 Thread rao fu
not know your "LgmFormula". I think you already defined it. Rao Fu Ph.D Yale University Department of Statistics Email: [EMAIL PROTECTED] >>Date: Wed, 10 Sep 2008 15:22:37 +0200 >>From: "Benoit Boulinguiez" <[EMAIL PROTECTED]> >>Subject: [R] writing

Re: [R] writing simple function through script

2008-09-10 Thread Dieter Menne
Benoit Boulinguiez ensc-rennes.fr> writes: > yo<-function(Xdata) > { > n<-length(Xdata[,1]) > > Lgm<-nls(formula=LgmFormula, > data=Xdata, > start=list(a=1500,b=0.1),weights=Xdata$Qe) > return(Lgm) > } > > After the execution of the script, when I call the function yo on data > called NC60.

Re: [R] writing simple function through script

2008-09-10 Thread Gabor Grothendieck
Its looking in environment(LgmFormula) for Xdata in order to evaluate Xdata$Qe in the weights argument so just specify weights = Qe. Alternately insert the following as the beginning of yo. It creates a new local LgmFormula but with its environment set to the current environment: environment(L

[R] writing simple function through script

2008-09-10 Thread Benoit Boulinguiez
Hi all, I try to write a simple function in a script. The script is as follows yo<-function(Xdata) { n<-length(Xdata[,1]) Lgm<-nls(formula=LgmFormula, data=Xdata, start=list(a=1500,b=0.1),weights=Xdata$Qe) return(Lgm) } After the execution of the script, when I call the function yo on d