---
title: "Getting Started with ggpop"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{01 Getting Started with ggpop}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse   = TRUE,
  comment    = "#>",
  dpi = 150,
  fig.asp = .9,
  fig.width = 6,
  fig.height = 5,
  out.width = "70%",
  fig.align = "center",
  message    = FALSE,
  warning    = FALSE
)
library(ggpop)
library(ggplot2)
library(dplyr)
```

`ggpop` is a `ggplot2` extension for creating icon-based population charts.
Icons from Font Awesome replace bars or dots to represent population
proportions visually.

## Quick example

```{r quick}
df_raw <- data.frame(
  sex = c("Female", "Male"),
  n   = c(55, 45)
)

df_plot <- process_data(
  data        = df_raw,
  group_var   = sex,
  sum_var     = n,
  sample_size = 40
) %>%
  mutate(icon = case_when(
    type == "Female" ~ "person-dress",
    type == "Male"   ~ "person"
  ))

ggplot() +
  geom_pop(
    data = df_plot,
    aes(icon = icon, color = type),
    size = 2.5, dpi = 72
  ) +
  scale_color_manual(values = c(Female = "#C0392B", Male = "#2980B9")) +
  theme_pop() +
  scale_legend_icon(size = 5) +
  labs(title = "Population by sex", color = NULL)
```

## Vignettes

| Vignette | Description |
|:---|:---|
| `process_data()` | Prepare count data for plotting |
| `geom_pop()` | Population icon grids |
| `geom_icon_point()` | Icon scatter plots |
| `fa_icons()` | Search Font Awesome icons |
| `Themes` | `theme_pop()`, `theme_pop_dark()`, `theme_pop_minimal()` |
| `Tips` | Rules, gotchas, and best practices |
