Re: [R] writing simple function through script

2008-09-11 Thread rao fu
Hi Benoit, If you are in the directory that contains your data, you can use > NC60 = read.table("NC60.DATA") # there are some arguments you can use in "read.table" OR >NC60 = read.table("path to your data/NV60.DATA") > yo(NC60) By the way, I do not know your "LgmFormula". I think you already

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