Re: [R] writing simple function through script

2008-09-11 Thread rao fu
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 simple function through script To: r-help@r-project.org Message-ID: 001601c91348$4b505a20$[EMAIL PROTECTED

[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

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:

Re: [R] writing simple function through script

2008-09-10 Thread Dieter Menne
Benoit Boulinguiez benoit.boulinguiez at 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