Cross references

STAT1003 – Statistical Techniques

Dr. Emi Tanaka

Australian National University

These slides are best viewed on a modern browser like Google Chrome on a desktop or laptop. Some interactive components may require some time to fully load.

Bibliography

  • BibTeX citation style format is used to store references in .bib files.
  • You can get most BibTeX citation for R packages citation function.
citation("ggplot2")
To cite ggplot2 in publications, please use

  H. Wickham. ggplot2: Elegant Graphics for Data Analysis.
  Springer-Verlag New York, 2016.

A BibTeX entry for LaTeX users is

  @Book{,
    author = {Hadley Wickham},
    title = {ggplot2: Elegant Graphics for Data Analysis},
    publisher = {Springer-Verlag New York},
    year = {2016},
    isbn = {978-3-319-24277-4},
    url = {https://ggplot2.tidyverse.org},
  }

Citing literature

---
bibliography: ref.bib
---

You can cite references like:

- Data analysis was conducted using R [@rstats]
- @ggplot2 was used for plotting.



You can cite references like:

References

R Core Team. 2025. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.
  • You can cite references in the text using [@key] or @key, where key is the citation key defined in the .bib file.
  • References are automatically appended at the end of the document.
ref.bib
@Book{ggplot2,
    author = {Hadley Wickham},
    title = {ggplot2: Elegant Graphics for Data Analysis},
    publisher = {Springer-Verlag New York},
    year = {2016},
    isbn = {978-3-319-24277-4},
    url = {https://ggplot2.tidyverse.org},
  }

@Manual{rstats,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2025},
    url = {https://www.R-project.org/},
  }

Figure references

The chunk label with prefix fig- can be referenced in text as a figure.


The body mass distribution of penguins is shown in @fig-hist.


```{r}
#| label: fig-hist
#| fig-cap: "Distribution of penguin body mass."
library(ggplot2)
ggplot(penguins, aes(body_mass)) + 
    geom_histogram(bins = 30)
```




The body mass distribution of penguins is shown in Figure 1.

Figure 1: Distribution of penguin body mass.
  • Above we use the ggplot2 package to create a figure, but you can use base R plotting functions or other packages.

Table references

The chunk label with prefix tbl- can be referenced in text as a table.


```{r}
#| label: tbl-cars
#| tbl-cap: "Summary statistics of penguin body mass by species."
library(dplyr)
penguins |> 
 summarise(Mean = mean(body_mass, na.rm = TRUE),
           SD = sd(body_mass, na.rm = TRUE),
           N = n(),
           .by = species) |> 
 knitr::kable(digits = 1)
```


Table 1: Summary statistics of penguin body mass by species.
species Mean SD N
Adelie 3700.7 458.6 152
Gentoo 5076.0 504.1 124
Chinstrap 3733.1 384.3 68
  • Above we use the knitr::kable() function to create a table.
  • There are many other packages to create tables, e.g., gt, flextable, kableExtra, etc.

Section references

If you have enabled numbering of sections:

---
number-sections: true
---

then you can refer to them by their label prefixed by sec-.


## Introduction

To see the main results, go to 
@sec-results.

## Results {#sec-results}

The method works!


1 Introduction

To see the main results, go to Section 2.


2 Results

The method works!

Summary

Weave together text, code, and output (figures, tables, etc.) in a single document using Quarto into various output formats (HTML, PDF, Word, etc.).

  • Use YAML to control document’s meta data.
  • Use Markdown syntax in the body of the document to write content.
  • Use R (or Python, Julia, etc.) for data analysis and visualization.
  • Focus on writing the content instead of formatting!
  • The best guide for Quarto is at https://quarto.org/docs/guide/.

Quarto cheatsheet