Skip to content

Instantly share code, notes, and snippets.

@richarddmorey
Created October 23, 2019 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richarddmorey/3f20bc79ef622e1d827b07d85daed3be to your computer and use it in GitHub Desktop.
Save richarddmorey/3f20bc79ef622e1d827b07d85daed3be to your computer and use it in GitHub Desktop.
---
title : "The title"
shorttitle : "Title"
author:
- name : "First Author"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Postal address"
email : "my@email.com"
- name : "Ernst-August Doelle"
affiliation : "1,2"
affiliation:
- id : "1"
institution : "Wilhelm-Wundt-University"
- id : "2"
institution : "Konstanz Business School"
authornote: |
Add complete departmental affiliations for each author here. Each new line herein must be indented, like this line.
Enter author note here.
abstract: |
One or two sentences providing a **basic introduction** to the field, comprehensible to a scientist in any discipline.
Two to three sentences of **more detailed background**, comprehensible to scientists in related disciplines.
One sentence clearly stating the **general problem** being addressed by this particular study.
One sentence summarizing the main result (with the words "**here we show**" or their equivalent).
Two or three sentences explaining what the **main result** reveals in direct comparison to what was thought to be the case previously, or how the main result adds to previous knowledge.
One or two sentences to put the results into a more **general context**.
Two or three sentences to provide a **broader perspective**, readily comprehensible to a scientist in any discipline.
<!-- https://tinyurl.com/ybremelq -->
keywords : "keywords"
wordcount : "X"
bibliography : ["r-references.bib"]
floatsintext : no
figurelist : no
tablelist : no
footnotelist : no
linenumbers : yes
mask : no
draft : no
documentclass : "apa6"
classoption : "man"
output : papaja::apa6_pdf
---
```{r setup, include = FALSE}
library("papaja")
library("apa")
library("ggplot2")
library("dplyr")
```
```{r analysis-preferences}
# Seed for random number generation
set.seed(42)
knitr::opts_chunk$set(cache.extra = knitr::rand_seed)
```
# Methods
We report how we determined our sample size, all data exclusions (if any), all manipulations, and all measures in the study. <!-- 21-word solution (Simmons, Nelson & Simonsohn, 2012; retrieved from http://ssrn.com/abstract=2160588) -->
## Participants
```{r}
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"),
party = c("Democrat","Independent", "Republican"))
```
There were $N=`r sum(M)`$ participants.
## Material
## Procedure
## Data analysis
We used `r cite_r("r-references.bib")` for all our analyses.
\[
X^2(ij) = \sum_i \sum_j \frac{(O_{ij} - E_{ij})^2}{E_{ij}}
\]
# Results
```{r}
Xsq <- chisq.test(M)
```
```{r testtable, results = "asis"}
## Create a table
as.data.frame.table(M) %>%
group_by(gender) %>%
mutate(percent = 100 * Freq / sum(Freq)) %>%
papaja::apa_table(caption = "This is a table caption.")
```
```{r testfigure,fig.cap="This is a figure caption."}
## Create a figure
as.data.frame.table(M) %>%
group_by(gender) %>%
mutate(percent = 100 * Freq / sum(Freq)) %>%
ggplot(aes(x = party, y = percent, group = gender, fill = gender)) +
geom_bar(stat = "identity") +
facet_wrap(~ gender)
```
This is a result: `r apa::chisq_apa(Xsq, format = "rmarkdown", print=FALSE)`. See Table \@ref(tab:testtable) and Figure \@ref(fig:testfigure).
# Discussion
\newpage
# References
```{r create_r-references}
r_refs(file = "r-references.bib")
```
\begingroup
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
<div id = "refs"></div>
\endgroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment