latex - xtable rownames using R -
i using r , latex , xtable bundle tables. little puzzled why specified rownames aren't showing in tables. here's example:
\documentclass[a4paper, 11pt]{article} \usepackage[english]{babel} \usepackage[t1]{fontenc} \begin{document} \sweaveopts{concordance=true} <<results=tex, fig=false, echo=false>>= library(xtable) table.matrix <- matrix(numeric(0), ncol = 5, nrow = 12) colnames(table.matrix) <- c("$m_t$", "$p_t$", "$r^b_t$", "$r^m_t$", "$y^r_t$") rownames(table.matrix) <- c("$m_{t-1}$", " ", "$p_{t-1}$", " ", "$r^b_{t-1}$", " ", "$r^m_{t-1}$", " ", "$y^r_t$", " ", "$c$", " ") tex.table <- xtable(table.matrix) align(tex.table) <- "c||ccccc" print(tex.table, include.rownames = true, hline.after = c(-1, 0, seq(0, nrow(table.matrix), = 2)), sanitize.text.function = function(x){x}) @ \end{document}
it seems pretty straightforward me. have estimation of simple var model , in rows want variables (t-1) subscript, , every sec row should have p-values (they're empty right in name vector). ideas?
edit: pointed out nograpes, issue rownames duplicates. know how circumvent (without using first column name column)? want evenly numbered rows empty, alternatively sort of indication p-values.
try running r code, , you'll warning tells why row names aren't showing up:
library(xtable) table.matrix <- matrix(numeric(0), ncol = 5, nrow = 12) colnames(table.matrix) <- c("$m_t$", "$p_t$", "$r^b_t$", "$r^m_t$", "$y^r_t$") rownames(table.matrix) <- c("$m_{t-1}$", " ", "$p_{t-1}$", " ", "$r^b_{t-1}$", " ", "$r^m_{t-1}$", " ", "$y^r_t$", " ", "$c$", " ") xtable(table.matrix) # warning message: # in data.row.names(row.names, rowsi, i) : # row.names duplicated: 4,6,8,10,12 --> row.names not used
so can't have duplicated rownames
in r. solve making name "column" instead of using rownames
.
r latex sweave xtable
No comments:
Post a Comment