---
title: "テスト"
date: "2022/1/23"
output:
  pdf_document:
    latex_engine: xelatex
highlight: "zenburn"
mainfont: ipaexg.ttf
---
 
# ggplot2での日本語設定
#以下を設定する。一度設定すればOK。チャンクにinclude=FALSEを追記すると良い。
```{r setup, include=TRUE}
knitr::opts_chunk$set(dev = "cairo_pdf", dev.args = list(family = "ipaexg"))
# パッケージの読み込み
library("tidyverse")
 
# データ例の作成
n <- 100
TestData <- data.frame(Group = sample(paste0("グループ", 1:5),
                                      n, replace = TRUE),
                       Data = sample(c("か", "ら", "だ", "に", "い", "い",
                                       "も","の"), n, replace = TRUE))
```
 
# プロット
```{r, fig.cap="キャプションも日本語でオッケー", include=TRUE, fig.width=4, fig.height=4}
ggplot(TestData, aes(x = Group, y = Data)) + geom_point()
```