# Knit the document using the Command + Shift + K shortcut (or by clicking the "knit" button at the top of your source editor)
library() # load papaja
library(yarrr) # To get the pirates dataframe
# ---------------------
# Show APA syle conclusions from a t.test object
# ------------------
# t.test comparing the ages of male and female pirates
sex_age_ttest <- t.test(formula = age ~ sex,
data = pirates,
subset = sex %in% c("male", "female"))
# Create apa style outputs from sex_age_ttest
sex_age_ttest_apa <- apa_print(sex_age_ttest)
# Show all output types
sex_age_ttest_apa
# Here are the different types of outputs
names(sex_age_ttest_apa)
# Full output
sex_age_ttest_apa$full_result
# $\\Delta M = -4.96$, 95\\% CI $[4.29$, $5.62]$, $t(949.43) = 14.53$, $p < .001$
# ---------------------
# Show APA syle conclusions from an lm (regression) object
# ------------------
# regression comparing tattoos as a function of sex, headband, and age
tattoos_lm <- lm(formula = tattoos ~ sex + headband + age,
data = pirates)
# Create apa style outputs from tattoos_lm
tattoos_lm_apa <- apa_print(tattoos_lm)
# Look at all outputs
tattoos_lm_apa
# Full result for age
tattoos_lm_apa$full_result$age
# Here is the full APA style conclusion for age
# $b = 0.02$, 95\\% CI $[-0.02$, $0.05]$, $t(995) = 0.96$, $p = .340$
# ---------------------
# Show APA syle conclusions from an Anova object
# ------------------
# Create anova object from tattoos_lm
# In this example I'm conducting a type II anova using car::Anova
tattoos_aov <- car::Anova(tattoos_lm)
# Get apa style results
tattoos_aov_apa <- apa_print(tattoos_aov)
# Look at all outputs
tattoos_aov_apa
# Full result for sex
tattoos_aov_apa$full_result$sex
# ANOVA table
tattoos_aov_apa$table
# ---------------------
# Show a APA style table of data
# ------------------
# Convert a dataframe to an APA formatted LaTeX table
apa_table(pirates[1:10, c("id", "sex", "age", "tattoos", "tchests")],
caption = "First few rows of the pirates dataframe")
Create a new R project called studentAPA.RProj
Navigate to the project directory (the one you just put studentAPA.RProj in). Create two new folders R and data in your project directory.
The two data files you need for this assignment are located at https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/data/studentmath.txt (https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/data/studentmath.txt) (the mathdata) and https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/data/studentpor.txt (https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/data/studentpor.txt) (the portugesedata), we need to get these files into your data folder. To do this, open a new script. Then run code to save both data files into your data folder,
Open a new R Markdown document using the papaja template. Save the file in the top level of your working directory (that is, next to the studentAPA.Rproj ) as studentAPA.Rmd
Knit the document to see a simple APA style document! Do this by clicking the Knit button at the top of your source window, or by using the Command + Shift + K shortcut.
In a web browser, go to https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/studentAPA/studentAPA_blank.Rmd (https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/studentAPA/studentAPA_blank.Rmd)
Copy all of the text, and paste it into your studentAPA.Rmd file (replace all of the text that was there before). Save the file.
Open a new text file by clicking File – New File – Text File. Save the file in the top level of your working directory as studentAPA.bib
In a web browser, go to https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/studentAPA/studentAPA.bib (https://raw.githubusercontent.com/ndphillips/IntroductionR_Course/master/assignments/wpa/studentAPA/studentAPA.bib) .Copy all of the text, and paste it into your studentAPA.bib file. Save the file.
Your goal is to create the following APA document( https://github.com/ndphillips/IntroductionR_Course/blob/master/assignments/wpa/studentAPA/studentAPA_comp.pdf?raw=true) ) by adding elements to the studentAPA.Rmd document. In a web browser, go to the link above to download the studentAPA_comp.pdf file and see how it looks.
In studentAPA.Rmd, replace the X values in the main fields at the top of the document (name, paper title, short-title, affiliation) with the appropriate names and titles.
Now Knit your document to see the current version of the PDF output! You can do this by clicking the “Knit” button at the top of your window or by using the Command + Shift + K shortcut (on Mac).
In the Results section, I’ve included a chunk called fig1 that creates Figure 1, a series of histograms. Update the caption to the plot in the chunk options. Then change eval = FALSE to eval = TRUE to tell Markdown to run the chunk. Knit your document to see the result. You should now see the histograms in your document!
There is another chunk called fig2 that plots the correlations between numeric predictors in the math data. Turn on the chunk by setting eval = TRUE , update the caption. Knit your document to see the result