label - 如何将下标添加到观星表协变量标签?
问题描述
在下面的协变量标签中,我想在下标中包含 P、M 和 C。这是我的代码:
stargazer(DD1_PT, DD1_MT, DD1_CT,
type = "text",
title = "Table 1",
out = "table1.html",
dep.var.labels.include = FALSE,
column.labels = c("Presidential", "Midterm", "Constitutional"),
model.numbers = FALSE,
order=c(4, 1, 8, 2, 9, 3, 10, 5, 6, 7),
covariate.labels=c("TimeP (1 = 2016/0 = 2012)","TimeP*Vote center", "TimeM (1 = 2018/0
= 2010)", "TimeM*Vote center", "TimeC (1 = 2017/0 = 2009)", "TimeC*Vote center"),
no.space=TRUE,
omit.stat=c("LL","ser","f"),
notes = c("Standard errors given in parentheses ", "Population scaled to 1,000,000 and
income scaled to 10,000"),
notes.align = "r"))
关于我如何做到这一点的任何想法?
谢谢!
解决方案
您的代码具有type = "text"
. 在纯文本中制作下标字符会很困难。
如果您将输出设置为html
,那么您可以使用stringr::str_replace()
在 HTML 中放入下标:<sub> <\sub>
。
对于可重现的示例,让我们使用mtcars
:
想象一下,我们想让“Observations”的最后一个字母在表格中下标。
图书馆(观星者) 图书馆(tidyverse) fit1 <- lm(mpg ~ cyl, 数据 = mtcars) output <- stargazer(fit1, type = "HTML") # 给你输出 # 用下标的 html 替换输出 输出<-str_replace(输出,“观察”,“观察<sub>s</sub>”) write_lines(输出,“subscript_example.html”)
它给出了所需的下标,如下所示:
作为最后一点,我已经读到最好使用编辑 HTMLxml2
而不是str_replace()
. 也许其他人可以提供帮助。上述解决方案对我有用。
推荐阅读
- apache-nifi - 如何使用 NiFi 拆分文本文件中的列?
- entity-framework - 实体框架:在哪里查找
- python - 当我在 Django Admin 中删除或添加对象时,它不会在网页上删除或添加?
- python-3.x - 连接到设备并使用 paramiko 打开 shell
- xml - WCF XML 序列化消息格式
- android - FCM BigQuery - 未返回 MESSAGE_DELIVERED 记录
- javascript - Firebase 安全规则不显示任何数据
- jquery - 使用 jQuery 检测输入值变化的更智能方法
- xamarin - 如何为 Xamarin Forms 中的 CollectionView 项目位置设置动画
- python - 找不到 tensorflow 版本