【问题标题】:How to render R stargazer output using rpy2 in ipython jupyter notebook?如何在 ipython jupyter notebook 中使用 rpy2 渲染 R stargazer 输出?
【发布时间】:2019-04-15 17:21:55
【问题描述】:

我希望在 ipython jupyter notebook 中显示格式良好的回归表。我使用 rpy2 运行回归并在 stargazer for R 中收集输出。如何在笔记本中很好地渲染表格?我想要看起来像这样的代码:

%%R
summary(diamonds)
reg1 <- lm(price ~ carat, data=diamonds)
reg2 <- lm(price ~ carat + depth, data=diamonds)
display_html(stargazer(reg1, reg2))

【问题讨论】:

  • 我目前的解决方法是使用huxtable 库函数export_summs,但是让stargazer 在这种环境中工作会很棒。

标签: r jupyter-notebook rpy2 stargazer


【解决方案1】:

Stargazer 在 jupyter 笔记本中正确渲染,选项 type = "text"。

stargazer(reg1, reg2, type="text")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-19
    • 2019-09-22
    • 2021-02-06
    • 1970-01-01
    • 2020-02-28
    • 2018-10-25
    • 2017-10-15
    • 2021-02-23
    相关资源
    最近更新 更多