Main paper sections
Notice that we set the chunk options so that chunks will run, but not echo their outputs or show warning or error messages.
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, error = FALSE)
This keeps the final output clean.
We load the required packages for our paper, and then write our introduction.
It is possible to write an entire APA-formatted article in R Markdown.
This very brief paper shows how it might be done.
As illustration, we use the data from a short, informal survey of participants in the 2018 R Bootcamp at Penn State.
The methods section is specified as a level 1 #
heading, with the subsections denoted by level 2 ##
headings.
# Methods {#methods}
Consistent with open and transparent science practices, we report how we determined our sample size, all data exclusions (if any), all manipulations, and all measures in the study [@Simmons2011-za].
## Participants {#participants}
We asked participants in an optional "R Bootcamp" held at the Pennsylvania State University Department of Psychology on August 16 and 17, 2018 to complete an anonymous survey using a Google Form.
We asked participants to report how old they felt.
A total of $n=$56 respondents answered the survey with a reported felt age of $M$=50.75 and a range of [5-1000] years.
The package uses the tags in braces {#methods}
in generating a table of contents. Notice that we can add in-text references using the [@paper_id]
syntax if we’ve created a bibliography file in the BibTex format (.bib). Notice also that we can freely mix LaTex syntax for equations ($n=$
becomes \(n=\)) with commands to produce R output 56. This allows us to directly ‘grab’ information from R, including statistical values, and insert them into our document without copying and pasting.
Text between dollar signs $x=12$
will be rendered using the LaTex equation engine. Text between single backticks will be run in the language specified by the first element, here that is r
.