请考虑以下 MWE
library(xtable)
DF <- as.data.frame(UCBAdmissions)
print(xtable(DF, align="p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}"), sanitize.text.function = function(x){x},
table.placement="!htp", include.rownames=FALSE,
tabular.environment='longtable',floating=FALSE)
我想设置我longtable
喜欢的对齐方式
\begin{longtable}{p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}}
仍然当我尝试将参数传递给xtable
我得到的对象时
Warning message:
In .alignStringToVector(value) : Nonstandard alignments in align string
Error in print(xtable(DF, align = "p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}"), :
error in evaluating the argument 'x' in selecting a method for function 'print': Error in `align<-.xtable`(`*tmp*`, value = "p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}") :
"align" must have length equal to 5 ( ncol(x) + 1 )
我知道我应该为第 5 列添加对齐方式(如何?),但我也不理解错误消息。我应该清理字符串吗?