-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft make_project paper (gits) files
- Loading branch information
1 parent
57cd4c3
commit d946b9d
Showing
2 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
title: "your_title_goes_here" | ||
author: "your_name_goes_here" | ||
date: "`r Sys.Date()`" | ||
output: | ||
bookdown::html_document2: | ||
number_sections: false | ||
--- | ||
|
||
```{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 | ||
) | ||
# 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 | ||
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 analysis-1} | ||
# preprocess your data and ultimately make a dataset called analysis | ||
analysis <- mtcars |> | ||
mutate(auto_man = if_else(am == 0, "Automatic", "Manual")) |> | ||
select(mpg, auto_man) | ||
``` | ||
|
||
# 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")`), `table1` (`r packageVersion("table1")`) packages used to preprocess and summarize data.[@R-base; @R-tidyverse; @tidyverse2019; @R-rUM; @R-table1] | ||
|
||
# Results | ||
|
||
```{r table-1} | ||
# The table1::table1 does quick pretty descriptive tables but they don't support | ||
# hyperlinks/cross-references in the paper | ||
# | ||
# analysis |> | ||
# select(everything()) |> # choose your variables here | ||
# table1( | ||
# # change auto_man to the name of your column variable or delete | auto_man | ||
# ~ . | auto_man, | ||
# data = _ | ||
# ) | ||
analysis |> | ||
tbl_summary( | ||
include = c(everything()), # choose your variables here | ||
# change auto_man to the name of your column variable or delete by = auto_man | ||
by = auto_man, # split table by group | ||
missing = "no" # don't list missing data separately | ||
) %>% | ||
# add_n() %>% # add column with total number of non-missing observations | ||
# add_p() %>% # test for a difference between groups | ||
modify_header(label = "") %>% # update the column header to be blank | ||
bold_labels() |> | ||
modify_caption( | ||
"Cross references to tables start with tab: then the code chunk label." | ||
) | ||
``` | ||
|
||
As can be seen in Table \@ref(tab:table-1) or [Table 1](#tab:table-1) | ||
|
||
```{r} | ||
#| label: figure1 | ||
#| fig.cap: "Remember figure references begin with #fig:" | ||
analysis |> | ||
ggplot(aes(x=mpg)) + | ||
geom_histogram(bins = 5) + | ||
facet_wrap(vars(auto_man), ncol = 1) | ||
``` | ||
|
||
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" | ||
) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--- | ||
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 | ||
R.options: | ||
digits: 3 # round to three digits | ||
editor: visual | ||
--- | ||
|
||
```{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 analysis-1} | ||
# preprocess your data and ultimately make a dataset called analysis | ||
analysis <- mtcars |> | ||
mutate(auto_man = if_else(am == 0, "Automatic", "Manual")) |> | ||
select(mpg, auto_man) | ||
``` | ||
|
||
# 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")`), `table1` (`r packageVersion("table1")`) packages used to preprocess and summarize data.[@R-base; @R-tidyverse; @tidyverse2019; @R-rUM; @R-table1] | ||
|
||
# Results | ||
|
||
```{r} | ||
#| label: tbl-table1 | ||
#| tbl-cap: "Cross references to tables use labels for the code chunk starting with tbl-." | ||
# The table1::table1 does quick pretty descriptive tables but they don't support | ||
# hyperlinks/cross-references in the paper | ||
# | ||
# analysis |> | ||
# select(everything()) |> # choose your variables here | ||
# table1( | ||
# # change auto_man to the name of your column variable or delete | auto_man | ||
# ~ . | auto_man, | ||
# data = _ | ||
# ) | ||
analysis |> | ||
tbl_summary( | ||
include = c(everything()), # choose your variables here | ||
# change auto_man to the name of your column variable or delete by = auto_man | ||
by = auto_man, # split table by group | ||
missing = "no" # don't list missing data separately | ||
) %>% | ||
# add_n() %>% # add column with total number of non-missing observations | ||
# add_p() %>% # test for a difference between groups | ||
modify_header(label = "") %>% # update the column header to be blank | ||
bold_labels() | ||
``` | ||
|
||
As can be seen in @tbl-table1 .... | ||
|
||
```{r} | ||
#| label: fig-figure-1 | ||
#| fig-cap: "Remember figure labels begin with fig-" | ||
analysis |> | ||
ggplot(aes(x=mpg)) + | ||
geom_histogram(bins = 5) + | ||
facet_wrap(vars(auto_man), ncol = 1) | ||
``` | ||
|
||
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" | ||
) | ||
``` |