我正在使用 texreg package为我的 R 线性模型打印 LaTeX 表格。包的默认设置包括打印许多与我的分析无关的东西。幸运的是,该软件包提供了关闭许多功能的开关。
我通过反复试验发现,在 R 中设置为 single.row=TRUE 的东西可以在 RPy 中设置为 single_row=True。
正如您在我的 notebook example here 中看到的那样适用于 single_row,在随后的 latex 打印中,置信区间与我的值打印在同一行上。
选项 include_loglik 和 include_deviance 应该控制是否打印对数似然和偏差。因为我不是在比较模型,所以我不需要这些。我尝试通过多种不同的方法将它们设置为 false,但它根本行不通。
显然一切都在纯 R 中完美运行:
> texreg(lm, include.deviance=FALSE, include.loglik=FALSE)
Computing profile confidence intervals ...
Computing confidence intervals at a confidence level of 0.95. Use argument "method = 'boot'" for bootstrapped CIs.
\begin{table}
\begin{center}
\begin{tabular}{l c }
\hline
& Model 1 \\
\hline
(Intercept) & $1.85^{*}$ \\
& $[1.60;\ 2.10]$ \\
COIem-hard & $0.54^{*}$ \\
& $[0.38;\ 0.69]$ \\
COIsc-10 & $0.19^{*}$ \\
& $[0.03;\ 0.34]$ \\
COIsc-14 & $-0.04$ \\
& $[-0.20;\ 0.11]$ \\
COIsc-18 & $-0.04$ \\
& $[-0.20;\ 0.12]$ \\
COIsc-22 & $-0.01$ \\
& $[-0.16;\ 0.15]$ \\
COIsc-26 & $-0.13$ \\
& $[-0.29;\ 0.02]$ \\
COIsc-6 & $0.64^{*}$ \\
& $[0.48;\ 0.79]$ \\
\hline
AIC & 2342.49 \\
BIC & 2392.70 \\
Num. obs. & 1120 \\
Num. groups: ID & 7 \\
Variance: ID.(Intercept) & 0.08 \\
Variance: Residual & 0.45 \\
\hline
\multicolumn{2}{l}{\scriptsize{$^*$ 0 outside the confidence interval}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}
你能帮我通过 RPy 关闭那些开关吗?
请您参考如下方法:
这是因为这些命名参数没有在 R 函数 texreg::texreg 的签名中定义(这些参数通过省略号 ... 传递), rpy2 无法进行安全的转换尝试。
I have found through trial and error that thisgs set as single.row=TRUE in R can be set as single_row=True in RPy.
查阅文档是一个可供考虑的备选方案。查看: http://rpy.sourceforge.net/rpy2/doc-2.3/html/robjects_functions.html
