Skip to content

Instantly share code, notes, and snippets.

@RaymondBalise
Last active March 7, 2024 20:06
Show Gist options
  • Save RaymondBalise/224f0b7b107a6b800c610d46c8b6f236 to your computer and use it in GitHub Desktop.
Save RaymondBalise/224f0b7b107a6b800c610d46c8b6f236 to your computer and use it in GitHub Desktop.
Analysis Quarto Format
---
title: "your_title_goes_here"
author: "your_name_goes_here"
date: "`r Sys.Date()`"
format:
html:
self-contained: true
knitr:
opts_chunk: ########## set global options ############
collapse: true # keep code from blocks together (if shown)
echo: false # don't show code
message: true # show messages
warning: true # show warnings
error: true # show error messages
comment: "" # don't show ## with printed output
dpi: 100 # image resolution (typically 300 for publication)
fig-width: 6.5 # figure width
fig-height: 4.0 # figure height
R.options:
digits: 3 # round to three digits
editor: visual
bibliography: [references.bib, packages.bib]
csl: the-new-england-journal-of-medicine.csl
---
```{r tidyverse-tidymodels, echo=FALSE}
library(conflicted)
suppressPackageStartupMessages(library(tidymodels))
tidymodels_prefer()
suppressPackageStartupMessages(library(tidyverse))
# suppress "`summarise()` has grouped output by " messages
options(dplyr.summarise.inform = FALSE)
```
```{r other-packages}
library(glue) # for glue()
library(rUM) # needed for the bibliography
library(rio) # for import()
library(table1) # for table1()
# gtsummary for tbl_summary(), add_n(), add_p(), modify_header(), bold_labels()
suppressPackageStartupMessages(library(gtsummary))
```
```{r load-data}
# raw_data <- import("") # your data file goes inside the ""
```
```{r make-analysis}
# preprocess your data and ultimately make a dataset called analysis
```
# Abstract
# Introduction
# Methods
Analyses were conducted with `r stringr::word(R.Version()$version.string, 1, 3)` with the `tidyverse` (`r packageVersion("tidyverse")`), `rUM` (`r packageVersion("rUM")`), `gtsummary` (`r packageVersion("gtsummary")`) packages used to preprocess and summarize data. [@R-base; @R-tidyverse; @tidyverse2019; @R-rUM; @R-gtsummary]
# Results
```{r tbl-table1}
#| tbl-cap: "Cross references to tables use labels for the code chunk starting with tbl-."
```
As can be seen in @tbl-table1 ....
```{r fig-figure-1}
#| fig-cap: "Remember figure labels begin with fig-"
```
As can be seen in @fig-figure-1 ...
# Discussion
# References {.unnumbered}
```{r}
#| include: false
# automatically create a bib database for loaded R packages & rUM
knitr::write_bib(
c(
.packages(),
"rUM"
),
"packages.bib"
)
```
@RaymondBalise
Copy link
Author

move setup into header and add common options

@RaymondBalise
Copy link
Author

Version 1.1 edits (new chunks and other packages)

@RaymondBalise
Copy link
Author

move labels into {r}

@RaymondBalise
Copy link
Author

change label on make-analysis code block

@RaymondBalise
Copy link
Author

add more chunk options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment