[R] how to use paste in function for expression?

casperyc casperyc at hotmail.co.uk
Sat Dec 18 18:02:10 CET 2010


Hi all,
######################################
dof=c(1,2,4,8,16,32)
Q5=matrix(rt(100,dof),100,6,T,dimnames=list(NULL,dof))
par(mfcol=c(2,6))
for (i in 1:6){
	dof2=dof[i]
	hist(Q5[,i],main=paste("t[",dof2,"]",sep=""))
	qqnorm(Q5[,i])
	qqline(Q5[,i])
}
######################################

In this loop, I want to use
expression(t[1])
expression(t[2])
expression(t[4])
...

in the histogram as main title

how do I use expression and paste correctly?

I have tried 
hist(Q5[,i],main=expression(paste("t[",dof2,"]",sep="")))
does not work

Thanks.

casper
-- 
View this message in context: http://r.789695.n4.nabble.com/how-to-use-paste-in-function-for-expression-tp3093822p3093822.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list