Question

In xtable, is there any way to print a latex table without rownames, but while keeping & on the left hand side?

I also don't want to set the rownames to NA in my data matrix to achieve this feat.

Example:

require(xtable)
o <- do.call(cbind,lapply(1:10,function(i) matrix(rnorm(10)) ))
print(xtable(o))

We can see on the LHS of this output, there's 1,2,3,4,...,10. This is bad. I don't want this.

However

print(xtable(o),include.rownames=FALSE)

doesn't give me what I want because it deletes the & at the LHS of the matrix.

Was it helpful?

Solution

This builds on my response to your other post. I could not resolve the problem of the first row as pointed out by @Roman Luštrik (sorry the editing time limit threw me out of my comment) but it should, according to my understanding, take care of both your problems after manually inserting the first &:

o <- matrix( rnorm( 770, 10 ), ncol=10 )
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0:13,15:28,30:58,60:76)
addtorow$pos[[2]] <- c(14,29,59)
addtorow$command <- c( "&", "\\\\ \n &" )
print( xtable( o ), add.to.row = addtorow, include.rownames=FALSE )

Hope this makes your life (and that of your co-author) easier!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top