R语言 观星台:一列中的乳胶数学符号

yk9xbfzb  于 2023-01-15  发布在  其他
关注(0)|答案(1)|浏览(95)

我尝试使用Stargazer生成一个简单的data.frame表。第一列有一些数学符号,但Stargazer无法正确阅读。我执行了以下操作:

df_results <- data.frame('Variable' = c("$\\beta_{0}$"),
                         'Posterior Mean' =1,
                         'Posterior St. Dev.'=1,
                         check.names=FALSE)

stargazer(df_results,summary = F,table.placement = 'H')

我得到了这个结果:

\begin{table}[H] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}} cccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & Variable & Posterior Mean & Posterior St. Dev. \\ 
\hline \\[-1.8ex] 
1 & \$\textbackslash beta\_\{0\}\$ & $1$ & $1$ \\ 
\hline \\[-1.8ex] 
\end{tabular} 
\end{table}

如何删除反斜杠?

a64a0gku

a64a0gku1#

使用xtable怎么样?

---
title: "math symbols in summary"
author: "author"
date: "2023-01-12"
output:
  pdf_document: default
  html_document: default
subtitle: xtable
---

## data

```{r}
df_results <- data.frame('Variable' = c("$\\beta_{0}$"),
                         'Posterior Mean' =1,
                         'Posterior St. Dev.'=1,
                         check.names=FALSE)

print

library(xtable)
print(xtable(df_results),sanitize.text.function=function(x){x})

![](https://i.stack.imgur.com/d1yXj.png)

相关问题