为什么R函数print.xtableFtable忽略我的选项? [英] Why does R function print.xtableFtable ignore my options?
本文介绍了为什么R函数print.xtableFtable忽略我的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,print.xtableFtable忽略了乳胶的其他选项.
I am having the following code and print.xtableFtable ignores the additional options for latex.
##### Contingency tables - 34Y
library(xtable)
B <- ftable(prereg34Y_sub$employmentStatus34Y, prereg34Y_sub$ethnicity34Y, dnn=c("Unemployed", "NonBritish"))
sink("CTFemaleNonBrit34Y.tex", type="output")
print.xtableFtable(xtableFtable(B, method = "compact"), table.placement = "h!")
sink()
输出为:
% latex table generated in R 3.3.1 by xtable 1.8-2 package
% Sat Oct 22 18:08:35 2016
\begin{table}[ht]
\centering
\begin{tabular}{l |rr}
\hline
Unemployed $\vert$ NonBritish & \multicolumn{1}{l}{ 0} & \multicolumn{1}{l}{ 1} \\
\hline
0 & 2065 & 68 \\
1 & 31 & 2 \\
\hline
\end{tabular}
\end{table}
表的位置是ht而不是h!.有人知道为什么吗?
The position of the table is ht instead of h!. Does anyone have an idea why?
推荐答案
table.placement
参数似乎没有从print.xtableFtable
传递到print.xtable
,但是您可以设置可选的全局options(xtable.table.placement = "h!")
在运行print(xtableFtable(B))
It doesn't seem that the table.placement
argument gets passed along from print.xtableFtable
to print.xtable
, but you can set the optionally globally options(xtable.table.placement = "h!")
before running print(xtableFtable(B))
示例
library(xtable)
# table.placement doesnt seem to work
B <- ftable(mtcars$am, mtcars$cyl, dnn=c("Unemployed", "NonBritish"))
print(xtableFtable(B), table.placement = "h!")
# % latex table generated in R 3.3.1 by xtable 1.8-2 package
# % Sat Oct 22 18:00:52 2016
# \begin{table}[ht]
# ---
# ---
# But works for other data types
B2 <- table(mtcars$am, mtcars$cyl, dnn=c("Unemployed", "NonBritish"))
print(xtable(B2), table.placement = "h!")
# % latex table generated in R 3.3.1 by xtable 1.8-2 package
# % Sat Oct 22 18:00:52 2016
# \begin{table}[h!]
# ---
# ---
因此要全局设置选项
options(xtable.table.placement = "h!")
print(xtableFtable(B))
# % latex table generated in R 3.3.1 by xtable 1.8-2 package
# % Sat Oct 22 18:00:52 2016
# \begin{table}[h!]
# ---
# ---
这篇关于为什么R函数print.xtableFtable忽略我的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文