I am wondering how to set the names of the sockets of a matrix, including Greek letter expressions in R. I use an expression, but it seems to be inoperative. Here is my code below.
b.summary = matrix(0, 8, 6) colnames(b.summary)= c("Min.", "1st Qu.", "Median", "Mean","3rd Qu", "Max." ) rownames(b.summary)= c(expression(paste(tau, "=1", sep="")),expression(paste(sigma^2, "=1", sep="")), expression(paste(tau, "=5",sep="")), expression(paste(sigma^2, "=0.2",sep="")), expression(paste(tau, "=16", sep="")), expression(paste(sigma^2, "=0.0625",sep="")), expression(paste(tau, "1/2.25", sep="")),expression( paste(sigma^2, "=2.25", sep="")) )
When I type b.summary, the following are the names of the growths:
paste(tau, "=1", sep = "")
instead of latex expression.
The reason I need Greek letters is because I use knitr to create a dynamic document. I want to show the result of this matrix directly, and not create a table by manually typing all the elements of the matrix using the expression \ Sexpr {}. The full snippet of code in the bookie
<<coverage.b.summary, eval=TRUE, echo=FALSE>>= b.summary = matrix(runif(48), 8, 6) colnames(b.summary)= c("Min.", "1st Qu.", "Median", "Mean","3rd Qu", "Max." ) rownames(b.summary)= labels(expression(paste(tau, "=1", sep="")),expression(paste(sigma^2, "=1", sep="")), expression(paste(tau, "=5",sep="")), expression(paste(sigma^2, "=0.2",sep="")), expression(paste(tau, "=16", sep="")), expression(paste(sigma^2, "=0.0625",sep="")), expression(paste(tau, "=1/2.25", sep="")),expression( paste(sigma^2, "=2.25", sep="")) ) b.summary @
Thank you for your help!