---
title: "【PDF】Quarto で論文を書く"
author: "阿部洋輔"
date: 2024-07-08 # todayで今日の日付にできます
date-format: "YYYY年M月D日"
lang: en
format:
pdf:
documentclass: article
number-sections: true
include-in-header:
- text: |
\usepackage{zxjatype}
\usepackage[ipaex]{zxjafont}
execute:
echo: false # コードを表示しない
warning: false # 警告とメッセージを表示しない
language:
crossref-fig-title: "図"
crossref-tbl-title: "表"
crossref-eq-prefix: "式"
---
@tbl-regression が出力した表です。
```{r}
#| label: tbl-regression
#| tbl-cap: "iris を使用した回帰分析"
library(tidyverse)
library(fixest)
library(modelsummary)
library(tinytable)
# リスト形式で保存すると複数の分析結果を1つの表に表示可能
regression <- list(
"(1)" = iris |>
feols(Sepal.Length ~ Sepal.Width, se = "hetero"),
"(2)" = iris |>
feols(Sepal.Length ~ Sepal.Width + Petal.Length, se = "hetero"),
"(3)" = iris |>
feols(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width, se = "hetero")
)
# ここで変数名の表記を変更
cm <- c(
"Sepal.Width" = "がく片の幅(cm)",
"Petal.Length" = "花弁の長さ(cm)",
"Petal.Width" = "花弁の幅(cm)",
"Species" = "アイリスの種類"
)
# 表に加える統計量を整理
gm <- tibble(
"raw" = c("nobs", "r.squared"),
"clean" = c("Observations", "R\u00B2"),
"fmt" = c(0, 2)
)
# フットノートを書く
fn <- "注:標準誤差は括弧内に記載。+p < 10%, *p < 5%, **p < 1%"
msummary(regression, estimate = "{estimate}{stars}",
notes = fn, coef_map = cm, gof_map = gm,
stars = c("+" = .1, "*" = .05, "**" = .01)) |>
group_tt(j = list("がく片の長さ(cm)" = 2:4))
```