[R] nls fitting inside a loop in S-Plus

array chip arrayprofile at yahoo.com
Fri Aug 22 00:49:20 CEST 2003

Hi, this following problem is a S-Plus problem, I know
many guys here are also experts in S-plus, so I am
posting here, too.


I encountered a weird problem of fitting nls inside a
loop, it works well in R, but not in S-plus. The code



> par(mfrow=c(2,2))
> for (i in 1:2) {




When the above code was run in R, it worked very well,
but when it was run in S-plus, it gave me the
following error:

Problem in data.frameAux.list(x, na.strings =
na.strings, stringsAsFactors ..: arguments imply
differing number of rows: 4, 3,
 2, 16, 4, 4, 4, 4, 16, 1, 1, 1, 1 

Also, If I only run the loop for only 1 cycle (either
No.1 or No.2 by setting "for (i in 1:1)" or "for (i in
2:2)), the code worked ok in S-Plus, so the problem
has nothing to do with my data.

If I replace
"fit<-nls(signal~SSfpl(conc,A,B,xmid,scal))" with
"fit<-lm(signal~conc)", then the code worked well in
both R and S-Plus. So it seems the problem only
pertain to the "nls" function. Can anyone pinpoint the
problem for me?


More information about the R-help mailing list