# [Rd] a bug of function plot (PR#4405)

xzhao at stat.wvu.edu xzhao at stat.wvu.edu
Sat Oct 4 05:56:27 MEST 2003

```Full_Name: Ximing Zhao
Version: R 1.7.1
OS: MacOs X
Submission from: (NULL) (64.136.27.51)

When I used function plot in R 1.7.1, I found two bugs.
My whole function is this:
*****************
drawexp<-function(X,x,c,b){
exp<-function28(X,x,c,b)
if(max(exp)>=max(dexp(x,rate=1))){
plot(x,exp, type="l",main= paste("Exponential ,n=",length(X),"
c=",round(c,2),"b=",b),sub="X=exp(rate=1)")
lines(x,dexp(x,rate=1),col="red",type="l")
lines(density(X,width="SJ-dpi",n=1000,from=0.1,to=4),lty=2,col="blue")
}
else{
plot(x,dexp(x,rate=1),col="red",type="l",main= paste("Exponential
,n=",length(X)," c=",round(c,2),"b=",b),sub="X=exp(rate=1)")
lines(x,exp, type="l")
lines(density(X,width="SJ-dpi",n=1000,from=0.1,to=4),lty=2,col="blue")
}
text(3,0.25, "-- Kernel type", col="blue", adj=c(0,0))
}

function28<-function(X,x,c,b){
est<-function(X,x,alfa){
fx<-(1/gamma(alfa))*((alfa-1)/x)*(alfa*X/x)^(alfa-1)*exp(-alfa*X/x)
fx
}
n<-length(X)
result<-colSums(sapply(x,function(x){est(X,x,alfa=(n^c)*log(n)^b)}))/length(X)
result
}

X1<-rexp(100)

x1<-seq(0.1,4,length=100)

Run the function like this:

drawexp(X1,x1,0,0.5)

***************

For "lines(density(X,width="SJ-dpi",n=1000,from=0.1,to=4),lty=2,col="blue")",
only lty=1 works, lty=2 and others don't work. I tried the function in 1.6.2
before,
it was alright. So I am positive it's a bug. Please check.

Another thing is, if X11 window for the graph is not big enough, and the text,
like "-- moment type" in the function floats out, then X11 window doesn't show
the text at all. If you use the function in 1.6.2, it will show part of it but
not the characters beyond the graph size. I don't think it's reasonable to not
show anything. So it should be another bug.

I have a few suggestions, please keep the version which has been tested for a
long
time and with few bugs on the website(for different operating system), so
whenever people need some old good version they can still download from CRAN.
Also, please do not update the version of R in such a hurry way and let such
mistakes happen so easily. If you do update the version and want to introduce to
people, please mark it as "beta" so people will know. I understand this is a
free software and it's pretty hard to manage, but such efforts will be greatly
appreciated.

If you have any question w/ the bugs I described, please email me and I'd like
to
help.

Thank you very much!

```