0
我想與tabluar()
做一個簡單的雙向表,但我得到的是在輸出中是1。與表產生1的雙向表
爲什麼我的估計沒有顯示出來,而是我得到1的?
示例代碼
pred.table <- structure(list(temp = structure(c(1L, 2L, 3L, 4L, 5L, 1L, 2L,
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
5L, 1L, 2L, 3L, 4L, 5L), .Label = c("+1C", "+2C", "+3C", "+4C",
"+5C"), class = "factor"), crop = structure(c(1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L), .Label = c("A", "B", "C",
"D", "E"), class = "factor"), reg = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("CS", "DD", "P"
), class = "factor"), impact = c(-4.5, -11.15, -19.62, -29.37,
-39.8, -7.22, -19.77, -35.53, -51.96, -66.89, 0.47, -0.42, -2.79,
-6.66, -11.96, -9.02, -19.94, -32.06, -44.58, -56.66, -5.11,
-12.97, -23.04, -34.53, -46.57, 0.24, 0.28, 0.06, -0.45, -1.27,
-12.11, -24.4, -37.07, -49.95, -62.45, -11.67, -23.86, -36.03,
-47.69, -58.41, -4.15, -9.14, -14.91, -21.34, -28.29), se = c(2.39,
2.41, 2.44, 2.47, 2.5, 4.18, 4.11, 4.01, 3.91, 3.78, 2.13, 2.13,
2.14, 2.15, 2.16, 0.6, 0.62, 0.65, 0.69, 0.74, 0.82, 0.82, 0.83,
0.83, 0.83, 0.47, 0.48, 0.5, 0.51, 0.53, 2.47, 2.5, 2.55, 2.62,
2.72, 14.88, 14.96, 15.08, 15.23, 15.42, 8.3, 8.39, 8.49, 8.6,
8.74)), class = "data.frame", row.names = c(NA, -45L), .Names = c("temp",
"crop", "reg", "impact", "se"))
生成表
library(tables)
tab1 <- latex(tabular(temp ~ crop*reg*(impact + se), data = pred.table))
輸出
\begin{tabular}{lcccccccccccccccccccccccccccccc}
\hline
& \multicolumn{30}{c}{crop} \\
& \multicolumn{6}{c}{A} & \multicolumn{6}{c}{B} & \multicolumn{6}{c}{C} & \multicolumn{6}{c}{D} & \multicolumn{6}{c}{E} \\
& \multicolumn{6}{c}{reg} & \multicolumn{6}{c}{reg} & \multicolumn{6}{c}{reg} & \multicolumn{6}{c}{reg} & \multicolumn{6}{c}{reg} \\
& \multicolumn{2}{c}{CS} & \multicolumn{2}{c}{DD} & \multicolumn{2}{c}{P} & \multicolumn{2}{c}{CS} & \multicolumn{2}{c}{DD} & \multicolumn{2}{c}{P} & \multicolumn{2}{c}{CS} & \multicolumn{2}{c}{DD} & \multicolumn{2}{c}{P} & \multicolumn{2}{c}{CS} & \multicolumn{2}{c}{DD} & \multicolumn{2}{c}{P} & \multicolumn{2}{c}{CS} & \multicolumn{2}{c}{DD} & \multicolumn{2}{c}{P} \\
temp & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & se & impact & \multicolumn{1}{c}{se} \\
\hline
+1C & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
+2C & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
+3C & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
+4C & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
+5C & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
\hline
\end{tabular}