# Set the significant digits for each column in a xtable for fancy Sweave output

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**One R Tip A Day**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This tip may be useful in the situations when you need to set the number of digits to print for the different columns in a matrix/data.frame to be outputted as a LaTeX table.

For example:

`#install.packages("xtable")`

`#library(xtable)`

`tmp <- matrix(rnorm(9), 3, 3) xtmp <- xtable(tmp) digits(xtmp) <- c(0,0,3,4) print(xtmp, include.rownames = FALSE) # row names suppressed`

See here for a nice gallery depicting a large variety of outputs you can produce using the xtable package.

To

**leave a comment**for the author, please follow the link and comment on their blog:**One R Tip A Day**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.