xtable で使用される css を変更して、テーブルをフォーマットし、列の幅を変更できます。ただし、個々の列を変更することはできません。
http://nsaunders.wordpress.com/2012/08/27/custom-css-for-html-generated-using-rstudio/を参照してください。
以下に例を示します。
スタイルシート (ここでは custom.css という名前) をマークダウン ファイルと同じフォルダーに追加します。
table {
max-width: 95%;
border: 1px solid #ccc;
}
th {
background-color: #000000;
color: #ffffff;
width: 100px;
}
td {
background-color: #dcdcdc;
width: 100px;
}
このスタイルシートを使用するオプションを設定します
```{r setup, include=FALSE}
library(xtable)
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(markdown)
markdownToHTML(inputFile, outputFile, stylesheet='custom.css')
}
)
```
```{r, results="asis", echo=FALSE}
print(xtable(mtcars[1:2, 1:2]), type="html", include.rownames=FALSE)
```
print.xtable 関数をハックして柔軟性を高めることができるかもしれません。