Last active
March 7, 2024 20:04
-
-
Save RaymondBalise/ef56efda4a9260d8415a2cde94cbad1b to your computer and use it in GitHub Desktop.
Analysis R Markdown Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "your_title_goes_here" | |
author: "your_name_goes_here" | |
date: "`r Sys.Date()`" | |
output: | |
bookdown::html_document2: | |
number_sections: false | |
bibliography: [references.bib, packages.bib] | |
csl: the-new-england-journal-of-medicine.csl | |
--- | |
```{r setup, echo=FALSE} | |
knitr::opts_chunk$set( | |
########## set global options ############ | |
echo = FALSE, # don't show code | |
collapse = TRUE, # keep code from blocks together (if shown) | |
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's default rounding is to show 7 digits. This rounds results to 3 digits. | |
options(digits = 3) | |
``` | |
```{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 to include the package | |
library(rio) # for import() | |
library(table1) # for table1() if you want to use it instead of gtsummary | |
# 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 table-1} | |
``` | |
As can be seen in Table \@ref(tab:table-1) or [Table 1](#tab:table-1) | |
```{r figure1} | |
#| fig.cap: "Remember figure references begin with #fig:" | |
``` | |
See Figure \@ref(fig:figure1) or [Figure 1](#fig:figure1) | |
# Discussion | |
# References {-} | |
```{r include=FALSE} | |
# automatically create a bib database for loaded R packages & rUM | |
knitr::write_bib( | |
c( | |
.packages(), | |
"rUM" | |
), | |
"packages.bib" | |
) | |
``` |
Version 1.1 edits (new chunks and other packages)
change label on make-analysis code block
add more chunk options
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add more options to the setup chunk. This matches the
qmd
options.