【问题标题】:How can I insert long Rcode line in a LaTeX table with knitr如何使用 knitr 在 LaTeX 表中插入长 Rcode 行
【发布时间】:2013-10-07 23:43:21
【问题描述】:

在用knitr和Rstudio编写的Sweave文件中,由于R代码行长,在下一行自动拆分,报错。我的代码中有问题的行如下所示是第 6 行 有人如何进行?我认为只是需要一个小标志,但我没有在网上找到答案。

\begin{tabular}{@{}lr@{}} \toprule
Caracteristics & n, \% \\ \midrule
sexe (male) & \Sexpr{round(((prop.table(table(sexe)))[1]),2)*100} \%\\ 
Mean age at surgery (years) & \Sexpr{round(mean(agediag),1)} $\pm$        \Sexpr{round(sd(agediag),1)}\\
Main onset clinical sign & \\
\hspace{0.5cm} Motor deficit and dysphasia & \Sexpr{table(signeclinrevel)[1]}\\,  \Sexpr{formatPercent(prop.table(table(signeclinrevel))[1])}\\
\hspace{0.5cm} Seizure &   \\
\hspace{0.5cm} Cognitive disorders & \\
\hspace{0.5cm} Others (intracranial hypertension, eyesight troubles…) & \\

【问题讨论】:

标签: r latex knitr rstudio


【解决方案1】:

答案是,reporttools 包中的函数 formatPercent 在 Latex 表中不起作用。 相反,这项工作:

    \hspace{0.5cm} Motor deficit and dysphasia & \Sexpr{table(signeclinrevel)[1]}, (\Sexpr{round((prop.table(table(signeclinrevel))[1]*100),1)} \%)\\

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-05
    • 1970-01-01
    • 2012-12-14
    • 2012-10-03
    • 2021-08-21
    • 1970-01-01
    • 2017-10-30
    相关资源
    最近更新 更多