Skip to content

Instantly share code, notes, and snippets.

@tklebel
Last active June 17, 2016 19:49
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 tklebel/1e5331be700c6f57e7922176eea03130 to your computer and use it in GitHub Desktop.
Save tklebel/1e5331be700c6f57e7922176eea03130 to your computer and use it in GitHub Desktop.
# save test result as object
test_res <- t.test(examgrades$MeanGrade ~ examgrades$Semester)
# extract t and p values and format them
label <- paste(paste("t =", round(test_res$statistic, 2)),
paste("p =", format.pval(test_res$p.value, eps = .001)),
sep = ", ")
# add text with t-test result to figure
q1 <- q + annotate("text", x = 1, y = 85, label = label, size = 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment