[Rd] a bug of function plot (PR#4405)
Liaw, Andy
andy_liaw at merck.com
Sat Oct 4 00:36:37 MEST 2003
> From: xzhao at stat.wvu.edu [mailto:xzhao at stat.wvu.edu]
>
> 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.35,"-- theoretical",col="red",adj=c(0,0))
> text(3,0.3,"-- moment type", adj=c(0,0))
> 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,co
> l="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.
Works fine for me on WinXPPro...
> 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.
RTFM. Specifically, ?text says it accept the argument "xpd". To see how to
use it, see ?par. Also see R FAQ Q9.1.
> 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.
This is utterly unreasonable, IMHO. Try asking any commercial software
vendor to keep older versions of their software around for you to use. It
is your (or your sys admin's) responsibility to keep what you think is more
stable version of the software around *on your system*. If you think 1.7.1
is buggy and 1.6.2 is not, then don't erase 1.6.2. What we sometimes do is
keep two versions around for a while, just in case.
> 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.
1.8.0 is currently under beta. Are you testing it?
Andy
> If you have any question w/ the bugs I described, please
> email me and I'd like to
> help.
>
> Thank you very much!
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-devel
>
More information about the R-devel
mailing list