My question is regarding xtable and sweave. I have a certain table created in RStudio and want to create a pdf file using it. I use the package Sweave and write the necessary code and I get the table. Unfortunately, the rownames of the table are aligned to the right instead to the left. How can I avoid or rectify this? Any suggestions would be well appreciated.

 print(xtab,center = "centering", floating=FALSE)

1 Answer 1


when you do this, you need:

<<echo=false, results=hide>>= 
xtab <- xtable(ABC, align="lrrrrr")

the l will left align the row names. Please remember the align argument takes 1+ncol as the number of elements. So if you have 5 columns, you would do lrrrrr, if you have 4 columns, you would do lrrrr. Note: l=left, r=right, c=center.


<<echo=false, results=tex>>= 
print(xtab, floating=FALSE)

This should work. If you were using the knitr syntax, you would need, echo=FALSE, results='hide' and later, results='asis'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .