我有,我想在Rmarkdownxtable右對齊,並設置寬度Rmarkdown
---
title: "Test"
output:
pdf_document
---
```{r testing, results='asis'}
library(xtable)
df <- structure(list(ID = c(101L, 102L, 103L, 104L, 105L, 106L),
Gr1 = c(10.76,983.4, 34.000, 20, 23.8457, 13.32),
Gr2 = c(NA,NA, NA, 20L, NA, NA)
),
.Names = c("ID", "Grade1", "Grade2"),
class = c("tbl_df", "data.frame"),
row.names = c(NA, -6L))
xtable(df,
align = c('l', 'p{1.5in}', rep('r{0.5in}',2)),
digits=c(0,0,1,0))
```
與右對齊變成一個桌子給我的rep('r{0.5in}',2)
! LaTeX Error: Illegal character in array arg.
我的錯誤的數據幀「以前也試過:align = c('l|', 'p{1.5in}|', rep('R{0.5in}|',2))
下正常工作:align = c('l', 'p{1.5in}', rep('p{0.5in}',2))
但數據左對齊
我不明白你的觀點:如果你想做最後兩列,那麼'rep('r',2)'。只有參數'p'有一個寬度參數。 –
但是不會擺脫最後兩列的寬度參數嗎?我需要寬度和右對齊 – pluke
'r,l,c'默認情況下不帶寬度參數。您將需要創建一個自定義列類型,例如'R,L,C'來獲得所需的結果,您可以找到 [Here](http://stackoverflow.com/questions/33208777/how-to-set-both -column寬度和文本配向在對準參數的-的-xtable) – 9Heads