Hi, You can't access the column names from within apply, I'm afraid. This has been covered previously: http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg51014.html
That's one of the cases where you actually need to use a for() loop, though I suppose you could also write something vectorized on the column names themselves rather than the data frame. And also, you should check your colnames(Q5) - I don't think they are what you expect. Sarah On Sat, Dec 18, 2010 at 11:49 AM, casperyc <caspe...@hotmail.co.uk> wrote: > > Hi all, > > ########################################## > dof=c(1,2,4,8,16,32) > Q5=matrix(rt(100,dof),100,6,T,dimnames=list(NULL,dof)) > par(mfrow=c(2,6)) > apply(Q5,2,hist) > myf=function(x){ qqnorm(x);qqline(x) } > apply(Q5,2,myf) > ########################################## > > These looks ok. > However, I would like to achieve more. > > Apart from using a loop, > is there are fast way to 'add' the titles to be more informative? > > that is, in the histograms, I want the titles to be 't distribution with > dof=' the degrees of freedom. > > I have tried > apply(Q5,2,hist,xnames=dof) > which does not work; > apply(Q5,2,hist(,xnames=dof)); > does not work either > > and similarly, how do I add titles to qqnorm plot > to make them informative? > > Thanks! > > casper > > > -- -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ 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.