Two things:
1) doing log on rnorm, will get you NaN's because you are doing log on a
negative number (some of the time).

2) Running
> traceback()
5: sort(y)
4: qqplot(x, pch = 16, cex = pt.ht, col = palette()[c(1, 2)], xlab =
paste(colnames(x)),
       ylab = "Normal Quantile-Quantile Plot", main = "")
3: FUN(newX[, i], ...)
2: apply(z, 2, mtab.norm)
1: mtab.matrix(df)

Shows that you are using qqplot wrongly somehow.

Using
?qqplot
Shows that you should either use
qqnorm
(not qqplot)
Or have another argument for another distribution.


Let me know if it works :)

Best,
Tal




----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Galili@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




On Sat, May 29, 2010 at 12:39 PM, dunner <ross.dunne@tcd.ie> wrote:

>
> I have written a function to emulate minitab's QQ plotting output (with SW
> test and AD test results on the graph):
>
> mtab.norm<-function(x)
> { library(nortest)
> library(lattice)
> x<-as.numeric(x)
> x<-as.vector(x)
> plot.ht<-4.6
> plot.wd<-4.6
> pt.ht=plot.ht/5
> txt.sz<-(plot.ht/7.5)
> X11(width=plot.wd, height=plot.ht, bg='gray96')
> qqplot(x, pch=16, cex=pt.ht, col=palette()[c(1,2)],
> xlab=paste(colnames(x)),
> ylab='Normal Quantile-Quantile Plot', main='')
>
> grid(grid(col = "darkgray"))
> st.x<-shapiro.test(x)
>
> mtext(paste(st.x$method, "\np=",st.x$p.value,"\n W=",st.x$statistic,
> line=1,
> cex=txt.sz, adj=0))
>
> adt.x<-ad.test(x)
> mtext(paste(adt.x$method, "\np=",adt.x$p.value, "\n W=", adt.x$statistic,
> line=1, cex=txt.sz, adj=1))}
> mtab.matrix<-function(z){apply(z, 2, mtab.norm)}
>
> However,  I get the following message when I try to apply it:
>
> > ab<-rnorm(1:100, 2)
> > aa<-log(ab)
> Warning message:
> In log(ab) : NaNs produced
> > ac<-(ab^2)
> > df<-data.frame(aa,ab,ac)
>
> > mtab.matrix(df)
> Error in sort(y) : argument "y" is missing, with no default
>
> > mtab.norm(aa)
> Error in sort(y) : argument "y" is missing, with no default
>
> I'm doing something syntactically stupid. I can't figure out what.
>
> Thanks for your help
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/adding-statistical-output-to-a-plot-tp2235565p2235565.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org 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.
>

	[[alternative HTML version deleted]]

