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.