Hi I changed you function a little bit, so there is no more conflict in the if condition:
mecdf<-function(u,v,z) { u=sort(u) v=sort(v) n=length(u) m=length(z) nb <- numeric(m) for(j in seq(1,m)) { nb.temp=0 for (i in seq(1,n)) { if (u[i]<z[j] & v[i]<z[j]) { nb.temp<-nb.temp+1 } } nb[j]=nb.temp/n } return(nb) } Attention: I didn't look in detail what you did so you sould check my changes if it is really what you're looking for !! Best regards, Christoph -------------------------------------------------------------- Christoph Buser <[EMAIL PROTECTED]> Seminar fuer Statistik, LEO C11 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-5414 fax: 632-1228 http://stat.ethz.ch/~buser/ -------------------------------------------------------------- MEYFREDI Jean-Christophe writes: > Dear R users, > > > I'm trying to write a small function in order to compute empirical > cumulative density function.All seems to work but when I try to plot the > function, I always get error messages. > > This is the function I use > > mecdf<-function(u,v,z) { > u=sort(u) > v=sort(v) > n=length(u) > nb=0 > > for (i in seq(1,n)) { > if (u[i]<z & v[i]<z) { > nb<-nb+1 > } > } > nb=nb/n > return(nb) > } > > In fact if I try to obtain mecdf(u,v,0.1) or mecdf(u,v,0.2), all is > good, but with mecdf(u,v,c(0.1,0.2)), for example, I get errors and wrong > results for both mecdf(u,v,0.1) and mecdf(u,v,0.2). I think that it > consitutes the key point of my plot difficulty. Can someone help me ? > > Best regards > > JCM > > ______________________________________________ > 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 ______________________________________________ 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