I would like to keep the width of columns I set using align
argument of xtable
and I would like to align all numeric columns to the right, others to the left and the headers to the center.
I found some solutions using tables which are written directly in the rnw
file but I want to load my data from file because my table is quite big and can change during creation of the knitr document.
The code (I used the iris
dataset in this example instead of my own data):
<<table_symbionts_chunk, results="asis", echo=FALSE>>=
library(xtable)
irisX <-print (xtable (iris,
digits=rep(0,6),
align= c("p{0.015\\textwidth}|",
"p{0.37\\textwidth}|",
"p{0.12\\textwidth}|",
"p{0.08\\textwidth}|",
"p{0.02\\textwidth}|",
"p{0.35\\textwidth}|")))
@