Error in stepfun

hi may i pls be guided on this error. how will if fix it. my computations for k and cdf are correct. thanks!

k <- c(0,1,2,3,4)
cdf<-c(0.316,0.738,0.949,0.996,1.005)
plot(stepfun(k,cdf,f=0), xaxt="n", col=2, lwd=2,xlab="", ylab="CDF",verticals=FALSE,do.points=TRUE,main=" ",pch=18)
Error in stepfun(k, cdf, f = 0) : 'y' must be one longer than 'x'
axis(side=1,at=seq(-4, 4, 1),lwd=2)
mtext(side = 1, line=1.75, "x")

thank you, will work on this.

I corrected the last value. thanks again.

i tried that code and i still got an error. may i pls be guided to it?

mass_points<-c(0,1,2,3,4)
Warning messages:
1: In doTryCatch(return(expr), name, parentenv, handler) :
display list redraw incomplete
2: In doTryCatch(return(expr), name, parentenv, handler) :
invalid graphics state
3: In doTryCatch(return(expr), name, parentenv, handler) :
invalid graphics state
masses<-c(0.316,0.748,0.949,0.996,0.999)
plot(stepfun(mass_points,c(0,cumsum(masses))))
axis(side=1,at=seq(-5, 5, 1),lwd=2)
mtext(side = 1, line=1.75, "x")

thank you, will work on this.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.