3
votes

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.

1
Shoot missed the keeping & on the left side. This isn't a duplicate.Tyler Rinker
Check out two arguments: include.rownames=FALSE and add.to.rowTyler Rinker
It would be helpful if you provided some data - what you have and how you want it to look like afterwards. From your other post it seems you have a .txt file with the row names - why don't you import these row names into your R dataframe or matrix?vaettchen
That's much harder and less time efficient than what I'm already doing, and very confusing for my co-author. I will add an example here.Jase
@TylerRinker Funny, I can't get the first row to be affected by add.to.row.Roman Luštrik

1 Answers

8
votes

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!