You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用fixest包的etable函数为回归输出表添加列标题遇问题

问题:fixest包etable函数添加列标题失败

代码尝试

我用fixest包的etable函数给回归输出表添加列标题,先后试了向量和列表两种方式,代码如下:

# 先运行3个回归模型
est_header = feols(c(Ozone, Solar.R, Wind) ~  poly(Temp, 2), airquality)

# 尝试用向量添加标题
etable(est_header, headers = c("A", "A", "B"))

# 尝试用列表添加分组标题
etable(est_header, headers = list("A" = 2, "B" = 1))

遇到的问题

  • 用向量方式时直接报错:
Error in etable(est_header, headers = c("A", "A", "B")) : 
  The second element of '...' (named 'headers') is not valid: it should be a fixest object or a list, it is neither.
  • 用列表方式时,列标题并未成功显示。

解决方案

问题出在fixest版本的参数变更,旧版的headers参数在新版中已被替换,需使用对应新参数:

  1. 给每一列单独设置标题:使用colnames参数
etable(est_header, colnames = c("A", "A", "B"))
  1. 添加分组标题(前两列归为A组,第三列归为B组):使用groups参数,列表的键为分组名,值为对应列的索引范围
etable(est_header, groups = list("A" = 1:2, "B" = 3))

原因说明:新版fixest不再支持headers参数,旧版文档的示例不适用于当前版本,替换为上述参数即可正常添加标题。

内容的提问来源于stack exchange,提问作者Paul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 19:55:22