Thanks. Yes, gpdlow is indeed return a vector longer than one. The length of the vector is different for i in 1:12, each equals to length(var[,i][var[,i]<(p[,i][[2]]).
jim holtman wrote: > > What does > > gpdlow(var[,i][var[,i]<(p[,i][[2]]) > > return? Is it a vector; if so, how long? Your declaration of > >> returnlow<- matrix(,12) >> >> str(returnlow) > logi [1:12, 1] NA NA NA NA NA NA ... >> > > is a matrix of 12 rows and one column. You may be getting the error > message > is gpdlow is returning a vector longer than one. Do > > str(gpdlow(var[,i][var[,i]<(p[,i][[2]])) > > so that we can see what the data looks like. You still haven't provided a > self-contained example, so we can only guess at what is happening. > > > > On 7/5/07, livia <[EMAIL PROTECTED]> wrote: >> >> >> Thanks a lot. I have corrected this. But it still does not work. Any >> thought? >> >> Stephen Tucker wrote: >> > >> > You do not have matching parentheses in this line >> > returnlow <- gpdlow(var[,i][var[,i]<(p[,i][[2]]) >> > most likely there is a syntax error that halts the execution of the >> > assignment statement? >> > >> > >> > >> > --- livia <[EMAIL PROTECTED]> wrote: >> > >> >> >> >> Hi All, I am trying to make a loop for a function and I am using the >> >> following codes. "p" and "var" are some matrix obtained before. I >> would >> >> like >> >> to apply the function "gpdlow" for i in 1:12 and get the "returnlow" >> for >> >> i >> >> in 1:12. But when I ask for "returnlow" there are warnings and it >> turns >> >> out >> >> some strange result. >> >> >> >> for (i in 1:12){ >> >> gpdlow <- function(u){ >> >> p[,i]$beta -u*p[,i][[2]] >> >> } >> >> returnlow <- gpdlow(var[,i][var[,i]<(p[,i][[2]]) >> >> } >> >> >> >> >> >> -- >> >> View this message in context: >> >> http://www.nabble.com/Loop-and-function-tf4028854.html#a11443955 >> >> Sent from the R help mailing list archive at Nabble.com. >> >> >> >> ______________________________________________ >> >> R-help@stat.math.ethz.ch mailing list >> >> https://stat.ethz.ch/mailman/listinfo/r-help >> >> PLEASE do read the posting guide >> >> http://www.R-project.org/posting-guide.html >> >> and provide commented, minimal, self-contained, reproducible code. >> >> >> > >> > ______________________________________________ >> > R-help@stat.math.ethz.ch mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11445807 >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem you are trying to solve? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/Return-valus-for-different-numbr-of-rows-tf4028854.html#a11446408 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.