├── .Rbuildignore ├── .github ├── .gitignore ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature_request.md ├── no-response.yml └── workflows │ ├── R-CMD-check.yaml │ ├── needs-reply.yml │ └── remove-needs-reply.yml ├── .gitignore ├── .travis.yml ├── CITATION.cff ├── CODE_OF_CONDUCT.md ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── add_custom_effect_sizes.R ├── apa6_formats.R ├── apa_barplot.R ├── apa_beeplot.R ├── apa_factorial_plot.R ├── apa_interval.R ├── apa_lineplot.R ├── apa_num.R ├── apa_print.R ├── apa_print_BFBayesFactor.R ├── apa_print_anova.R ├── apa_print_emm_lsm.R ├── apa_print_glht.R ├── apa_print_glm.R ├── apa_print_htest.R ├── apa_print_list.R ├── apa_print_manova.R ├── apa_print_merMod.R ├── apa_print_nlme.R ├── apa_print_wsci.R ├── apa_results_table.R ├── apa_table.R ├── apa_violinplot.R ├── arrange_anova.R ├── calculations.R ├── cite_r.R ├── deprecated_defunct.R ├── fast_aggregate.R ├── generate_author_yml.R ├── glue_apa_results.R ├── in_paren.R ├── lookup_tables.R ├── onload.R ├── papaja.R ├── print_anova.R ├── print_model_comp.R ├── r_refs.R ├── remove_comments.R ├── revision_letter_format.R ├── theme_apa.R ├── tidy_es.R ├── transmute_df_into_label.R ├── utils.R ├── utils_docs.R ├── utils_plot.R ├── utils_text.R ├── variable_label.R └── word_title_page.R ├── README.Rmd ├── README.md ├── README_files ├── figure-gfm │ ├── dep-plot-1.png │ ├── stroop-ggplot-1.png │ └── stroop-plot-1.png ├── figure-html │ ├── dep-plot-1.png │ ├── stroop-ggplot-1.png │ └── stroop-plot-1.png └── libs │ ├── bootstrap │ ├── bootstrap-icons.css │ ├── bootstrap-icons.woff │ ├── bootstrap.min.css │ └── bootstrap.min.js │ ├── clipboard │ └── clipboard.min.js │ └── quarto-html │ ├── anchor.min.js │ ├── popper.min.js │ ├── quarto-syntax-highlighting.css │ ├── quarto.js │ ├── tippy.css │ └── tippy.umd.min.js ├── cran-comments.md ├── inst ├── CITATION ├── NEWS.html ├── NEWS.md ├── WORDLIST ├── apa_source_files.csl ├── example │ ├── example.docx │ ├── example.pdf │ ├── example.rmd │ ├── example.tex │ ├── example_files │ │ └── figure-latex │ │ │ ├── beeplot-1.pdf │ │ │ └── beeplot-1.png │ ├── r-references.bib │ └── references.bib ├── images │ ├── knitting.png │ └── template_selection.png ├── lua │ ├── abstract_to_meta.lua │ ├── docx_fixes.lua │ ├── label_quotes.lua │ ├── parse_metadata.lua │ └── reviewer_comment.lua ├── papaja_manuscripts.bib ├── rmarkdown │ └── templates │ │ ├── apa6 │ │ ├── resources │ │ │ ├── apa6_header_includes.tex │ │ │ ├── apa6_man.docx │ │ │ └── apa6_man_.docx │ │ ├── skeleton │ │ │ └── skeleton.Rmd │ │ └── template.yaml │ │ └── revision_letter │ │ ├── resources │ │ └── revision_letter.tex │ │ ├── skeleton │ │ └── skeleton.Rmd │ │ └── template.yaml └── rmd │ ├── apa6-annotated-no-disambiguation.csl │ ├── apa6-annotated.csl │ ├── apa6-no-disambiguation.csl │ ├── apa6.csl │ ├── apa7-annotated-no-disambiguation.csl │ ├── apa7-annotated.csl │ ├── apa7-no-disambiguation.csl │ └── apa7.csl ├── man ├── add_col_spanners.Rd ├── add_effect_sizes.Rd ├── add_equals.Rd ├── add_row_names.Rd ├── apa6_pdf.Rd ├── apa_barplot.Rd ├── apa_beeplot.Rd ├── apa_df.Rd ├── apa_factorial_plot.Rd ├── apa_factorial_plot_single.Rd ├── apa_interval.Rd ├── apa_lineplot.Rd ├── apa_num.Rd ├── apa_p.Rd ├── apa_prepare_doc.Rd ├── apa_print.BFBayesFactor.Rd ├── apa_print.Rd ├── apa_print.aov.Rd ├── apa_print.emmGrid.Rd ├── apa_print.glht.Rd ├── apa_print.glm.Rd ├── apa_print.htest.Rd ├── apa_print.list.Rd ├── apa_print.lme.Rd ├── apa_print.merMod.Rd ├── apa_print.papaja_wsci.Rd ├── apa_table.Rd ├── apa_violinplot.Rd ├── arrange_anova.Rd ├── arrange_regression.Rd ├── beautify.Rd ├── beautify_terms.Rd ├── brighten.Rd ├── canonize.Rd ├── cite_r.Rd ├── combine_plotmath.Rd ├── complete_observations.Rd ├── conf_int.Rd ├── corresponding_author_line.Rd ├── default_label.Rd ├── defaults.Rd ├── escape_latex.Rd ├── extract_apa_results_table.Rd ├── fast_aggregate.Rd ├── fetch_web_refs.Rd ├── fetch_zotero_refs.Rd ├── figures │ └── theme_apa.png ├── format_cells.Rd ├── generate_author_yml.Rd ├── glue_apa_results.Rd ├── hd_int.Rd ├── in_paren.Rd ├── indent_stubs.Rd ├── init_apa_results.Rd ├── lines.matrix.Rd ├── localize.Rd ├── lookup_tables.Rd ├── merge_tables.Rd ├── package_available.Rd ├── papaja.Rd ├── parse_bcp47.Rd ├── points.matrix.Rd ├── print_anova.Rd ├── print_model_comp.Rd ├── print_scientific.Rd ├── quote_from_tex.Rd ├── r_refs.Rd ├── remove_comments.Rd ├── render_appendix.Rd ├── revision_letter_pdf.Rd ├── sanitize_terms.Rd ├── se.Rd ├── sel.Rd ├── simple_codebook.Rd ├── sort_columns.Rd ├── sort_terms.Rd ├── strip_math_tags.Rd ├── summary.papaja_wsci.Rd ├── theme_apa.Rd ├── transmute_df_into_label.Rd ├── validate.Rd ├── word_title_page.Rd └── wsci.Rd ├── papaja.Rproj ├── tests ├── spelling.R ├── testthat.R └── testthat │ ├── data │ ├── lm_fit_output1.Rdata │ ├── lm_fit_output2.Rdata │ ├── lm_fit_output3.Rdata │ ├── lm_fit_output4.Rdata │ ├── lm_fit_output5.Rdata │ ├── mixed_data.rdata │ ├── ow_data.rdata │ ├── rm_data.rdata │ ├── tw_data.rdata │ └── tw_rm_data.rdata │ ├── helper-structure.R │ ├── test-generate_author_yml.R │ ├── test_apa6_formats.R │ ├── test_apa_factorial_plot.R │ ├── test_apa_num.R │ ├── test_apa_print.R │ ├── test_apa_print_BFBayesFactor.R │ ├── test_apa_print_anova.R │ ├── test_apa_print_emm_lsm.R │ ├── test_apa_print_glht.R │ ├── test_apa_print_glm.R │ ├── test_apa_print_htest.R │ ├── test_apa_print_manova.R │ ├── test_apa_print_merMod.R │ ├── test_apa_print_model_comp.R │ ├── test_apa_print_nlme.R │ ├── test_apa_print_wsci.R │ ├── test_apa_results_table.R │ ├── test_apa_table.R │ ├── test_apa_table.Rmd │ ├── test_apa_table.tex │ ├── test_calculations.R │ ├── test_custom_effect_sizes.R │ ├── test_lookup_tables.R │ ├── test_meta.R │ ├── test_print_anova.R │ ├── test_skeleton.R │ ├── test_theme_apa.R │ ├── test_transmute_df_into_label.R │ ├── test_utils.R │ └── test_utils_for_plots.R ├── tools └── images │ └── papaja_hex.png ├── update_csl.sh └── vignettes ├── .gitignore ├── extending_apa_print.Rmd ├── papaja.Rmd ├── papaja.pdf ├── papaja.pdf.asis ├── papaja.tex ├── r-references.bib └── references.json /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^Meta$ 2 | ^doc$ 3 | ^.*\.Rproj$ 4 | ^\.Rproj\.user$ 5 | 6 | ^README\.Rmd$ 7 | ^README_files$ 8 | ^cran-comments\.md$ 9 | ^\.travis\.yml 10 | ^.github$ 11 | ^inst/example$ 12 | ^_config.yml$ 13 | ^inst/papaja_manuscripts.bib 14 | ^inst/apa_source_files.csl 15 | ^CODE_OF_CONDUCT\.md$ 16 | ^\.github$ 17 | ^\.vscode$ 18 | ^update_csl.sh$ 19 | ^CITATION\.cff$ 20 | ^vignettes/papaja.Rmd$ 21 | ^vignettes/papaja.tex$ 22 | ^CRAN-SUBMISSION$ 23 | ^revdep$ 24 | ^.luarc.json$ 25 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to papaja 2 | 3 | This document outlines how to propose a change to **papaja**. 4 | 5 | ## Minor changes 6 | 7 | ### Fixing typos 8 | 9 | Small typos or grammatical errors in documentation may be edited directly using 10 | the [GitHub web interface](https://help.github.com/en/articles/editing-files-in-your-repository), so long as the changes are made in the _source_ file. 11 | 12 | * YES: you edit a roxygen comment preceeded by `#'` in a `.R` file below `R/`. 13 | * NO: you edit an `.Rd` file below `man/`. 14 | 15 | ## Substantial changes 16 | 17 | ### Prerequisites 18 | 19 | Before you make a substantial pull request, you should always file an issue and 20 | make sure someone from the team agrees that it’s a problem. 21 | If you’ve found a bug, create an associated issue and illustrate the bug with a minimal 22 | [reproducible example](https://www.tidyverse.org/help/#reprex). 23 | 24 | ### Pull request process 25 | 26 | * We recommend that you create a `git` branch for each pull request (PR). 27 | * Look at the GitHub action build status before and after making changes (Did you break anything?). 28 | The `README` should contain badges for any continuous integration services used 29 | by the package. 30 | * New code should follow the tidyverse [style guide](http://style.tidyverse.org). 31 | You can use the [styler](https://CRAN.R-project.org/package=styler) package to 32 | apply these styles, but please don't restyle code that has nothing to do with 33 | your PR. 34 | * We use [`roxygen2`](https://cran.r-project.org/package=roxygen2), with 35 | [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/markdown.html), 36 | for documentation. Please update any documentation to reflect your changes. 37 | * We use [`testthat`](https://cran.r-project.org/package=testthat). Contributions 38 | with test cases included are easier to accept. 39 | * We validate user input using either `validate()` or [`assertthat`](https://cran.r-project.org/package=assertthat) to ensure informative error messages. 40 | * For user-facing changes, add a bullet to the top of `NEWS.md` below the 41 | current development version header describing the changes made, followed by your 42 | GitHub username, and links to relevant issue(s)/PR(s). 43 | * If you are interested in adding new methods to `apa_print()`, please review the getting-started vignette (`vignette("add_apa_print_methods", package = "papaja")`). 44 | 45 | ### Code of Conduct 46 | 47 | Please note that the **papaja** project is released with a [contributor code of conduct](CODE_OF_CONDUCT.md). 48 | By contributing to this project you agree to abide by its terms. 49 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | 11 | 12 | **Describe the bug** 13 | A clear and concise description of what the bug is. 14 | 15 | **To Reproduce** 16 | A [minimal complete verifiable example](https://stackoverflow.com/help/minimal-reproducible-example) and the error message if applicable. 17 | 18 | **Expected behavior** 19 | A clear and concise description of what you expected to happen. 20 | 21 | **Screenshots** 22 | If applicable, add screenshots to help explain your problem. 23 | 24 | **Additional context** 25 | Add any other context about the problem here. 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 28 5 | # Label requiring a response 6 | responseRequiredLabel: more-information-needed 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because there has been no response 10 | to our request for more information from the original author. With only the 11 | information that is currently in the issue, we don't have enough information 12 | to take action. Please reach out if you have or find the answers we need so 13 | that we can investigate further. 14 | -------------------------------------------------------------------------------- /.github/workflows/needs-reply.yml: -------------------------------------------------------------------------------- 1 | name: Close old issues that need reply 2 | 3 | on: 4 | schedule: 5 | - cron: "0 18 * * *" 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Close old issues that need reply 12 | uses: dwieeb/needs-reply@v2 13 | with: 14 | repo-token: ${{ secrets.GITHUB_TOKEN }} 15 | issue-label: more-information-needed 16 | close-message: > 17 | This issue has been automatically closed because there has been no response 18 | to our request for more information from OP. With the information that is 19 | currently in the issue, we don't have enough information to take action. 20 | Please reach out if you have or find the answers we need so that we can 21 | investigate further. -------------------------------------------------------------------------------- /.github/workflows/remove-needs-reply.yml: -------------------------------------------------------------------------------- 1 | name: Remove more-information-needed label 2 | 3 | on: 4 | issue_comment: 5 | types: 6 | - created 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | if: | 12 | github.event.comment.author_association != 'OWNER' && 13 | github.event.comment.author_association != 'COLLABORATOR' 14 | steps: 15 | - name: Remove more-information-needed label 16 | uses: octokit/request-action@v2.x 17 | continue-on-error: true 18 | with: 19 | route: DELETE /repos/:repository/issues/:issue/labels/:label 20 | repository: ${{ github.repository }} 21 | issue: ${{ github.event.issue.number }} 22 | label: more-information-needed 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Meta 2 | doc 3 | # History files 4 | .Rhistory 5 | 6 | # Example code in package build process 7 | *-Ex.R 8 | # R data files from past sessions 9 | .Rdata 10 | .Rproj.user 11 | # System files 12 | *~ 13 | .DS_Store 14 | Thumbs.db 15 | .RData 16 | example/example_files 17 | example/example.tex 18 | inst/doc 19 | 20 | .vscode 21 | .luarc.json 22 | 23 | /.luarc.json 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: R 2 | r: 3 | - oldrel 4 | - release 5 | - devel 6 | 7 | pandoc_version: 2.3.1 8 | 9 | cache: packages 10 | 11 | # Be strict when checking our package 12 | warnings_are_errors: true 13 | 14 | # Suggested packages needed to run tests 15 | 16 | r_packages: 17 | - car 18 | - afex 19 | - lsmeans 20 | - multcomp 21 | - MBESS 22 | - ggplot2 23 | - dplyr 24 | - downloader 25 | - testthat 26 | - BayesFactor 27 | - latex2exp 28 | - covr 29 | 30 | # Install other dependencies # longtable lscape tabularx 31 | before_install: 32 | - tlmgr install apa6 booktabs caption csquotes endfloat environ etoolbox fancyhdr fancyvrb framed lineno microtype mptopdf ms parskip pgf sttools threeparttable threeparttablex trimspaces txfonts upquote url was xcolor 33 | 34 | after_success: 35 | - Rscript -e 'covr::codecov()' 36 | 37 | addons: 38 | apt: 39 | packages: 40 | - lmodern 41 | # - libgsl0ldbl # GNU scientific library for MBESS 42 | - libgsl-dev # GNU scientific library for MBESS 43 | - libnlopt-dev # nloptr 44 | 45 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------- 2 | # CITATION file created with {cffr} R package, v0.1.0 3 | # See also: https://docs.ropensci.org/cffr/ 4 | # ----------------------------------------------------------- 5 | 6 | cff-version: 1.2.0 7 | message: 'To cite package "papaja" in publications use:' 8 | type: software 9 | license: MIT 10 | title: 'papaja: Prepare American Psychological Association Journal Articles with R 11 | Markdown' 12 | version: 0.2.0 13 | abstract: Tools to create dynamic, submission-ready manuscripts, which conform to 14 | American Psychological Association manuscript guidelines. We provide R Markdown 15 | document formats for manuscripts (PDF and Word) and revision letters (PDF). Helper 16 | functions facilitate reporting statistical analyses or create publication-ready 17 | tables and plots. 18 | authors: 19 | - family-names: Aust 20 | given-names: Frederik 21 | email: frederik.aust@uni-koeln.de 22 | orcid: https://orcid.org/0000-0003-4900-788X 23 | - family-names: Barth 24 | given-names: Marius 25 | email: marius.barth@uni-koeln.de 26 | orcid: https://orcid.org/0000-0002-3421-6665 27 | preferred-citation: 28 | type: manual 29 | title: 'papaja: Prepare reproducible APA journal articles with R Markdown' 30 | authors: 31 | - family-names: Aust 32 | given-names: Frederik 33 | - family-names: Barth 34 | given-names: Marius 35 | year: '2022' 36 | url: https://github.com/crsh/papaja 37 | repository-code: https://github.com/crsh/papaja 38 | url: https://github.com/crsh/papaja 39 | date-released: '2022-03-18' 40 | contact: 41 | - family-names: Aust 42 | given-names: Frederik 43 | email: frederik.aust@uni-koeln.de 44 | orcid: https://orcid.org/0000-0003-4900-788X 45 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | We are committed to making participation in this project a harassment-free experience for 8 | everyone, regardless of level of experience, gender, gender identity and expression, 9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 10 | 11 | Examples of unacceptable behavior by participants include the use of sexual language or 12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment, 13 | insults, or other unprofessional conduct. 14 | 15 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 18 | from the project team. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 21 | opening an issue or contacting one or more of the project maintainers. 22 | 23 | This Code of Conduct is adapted from the Contributor Covenant 24 | (https://www.contributor-covenant.org), version 1.0.0, available at 25 | https://contributor-covenant.org/version/1/0/0/. 26 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: papaja 2 | Title: Prepare American Psychological Association Journal Articles with 3 | R Markdown 4 | Version: 0.1.3 5 | Description: Tools to create dynamic, submission-ready manuscripts, which 6 | conform to American Psychological Association manuscript guidelines. We 7 | provide R Markdown document formats for manuscripts (PDF and Word) and 8 | revision letters (PDF). Helper functions facilitate reporting statistical 9 | analyses or create publication-ready tables and plots. 10 | Authors@R: c( 11 | person("Frederik", "Aust", email = "frederik.aust@uni-koeln.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-4900-788X")) 12 | , person("Marius", "Barth", email = "marius.barth@uni-koeln.de", role = c("aut"), comment = c(ORCID = "0000-0002-3421-6665")) 13 | , person("Birk", "Diedenhofen", email = "mail@birkdiedenhofen.de", role = c("ctb")) 14 | , person("Christoph", "Stahl", email = "christoph.stahl@uni-koeln.de", role = c("ctb")) 15 | , person("Joseph V.", "Casillas", email = "joseph.casillas@rutgers.edu", role = c("ctb")) 16 | , person("Rudolf", "Siegel", email = "rudolf.siegel@uni-saarland.de", role = c("ctb")) 17 | ) 18 | Date: 2024-10-23 19 | URL: https://github.com/crsh/papaja 20 | BugReports: https://github.com/crsh/papaja/issues 21 | Depends: 22 | R (>= 4.2), 23 | tinylabels (>= 0.2.4) 24 | Imports: 25 | bookdown (>= 0.41), 26 | broom (>= 1.0.7), 27 | glue (>= 1.8.0), 28 | knitr (>= 1.48), 29 | methods, 30 | rmarkdown (>= 2.28), 31 | rmdfiltr (>= 0.1.5), 32 | utils, 33 | yaml (>= 2.3.10), 34 | zip (>= 2.3.1) 35 | Suggests: 36 | afex, 37 | BayesFactor, 38 | beeswarm, 39 | boot, 40 | car, 41 | dplyr (>= 1.1.0), 42 | effectsize (>= 0.4.4), 43 | emmeans, 44 | ggforce, 45 | ggplot2, 46 | latex2exp, 47 | lme4, 48 | lmerTest, 49 | MASS, 50 | MBESS, 51 | multcomp, 52 | nlme, 53 | nnet, 54 | R.rsp, 55 | skimr, 56 | spelling, 57 | testthat, 58 | VGAM 59 | SystemRequirements: Rendering the document template requires 60 | pandoc (>= 2.0; https://pandoc.org) and for PDFs a TeX distribution, 61 | such as TinyTeX (>= 0.12; https://yihui.org/tinytex/) 62 | License: MIT + file LICENSE 63 | Encoding: UTF-8 64 | RoxygenNote: 7.3.2 65 | VignetteBuilder: knitr, R.rsp 66 | Language: en-US 67 | Roxygen: list(markdown = TRUE) 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2023 2 | COPYRIGHT HOLDER: Frederik Aust 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method("$",apa_results_table) 4 | S3method("[",apa_results_table) 5 | S3method("[[",apa_results_table) 6 | S3method(apa_barplot,afex_aov) 7 | S3method(apa_barplot,default) 8 | S3method(apa_beeplot,afex_aov) 9 | S3method(apa_beeplot,default) 10 | S3method(apa_factorial_plot,afex_aov) 11 | S3method(apa_factorial_plot,default) 12 | S3method(apa_interval,data.frame) 13 | S3method(apa_interval,default) 14 | S3method(apa_interval,list) 15 | S3method(apa_interval,matrix) 16 | S3method(apa_interval,numeric) 17 | S3method(apa_lineplot,afex_aov) 18 | S3method(apa_lineplot,default) 19 | S3method(apa_num,data.frame) 20 | S3method(apa_num,default) 21 | S3method(apa_num,integer) 22 | S3method(apa_num,list) 23 | S3method(apa_num,matrix) 24 | S3method(apa_num,numeric) 25 | S3method(apa_num,tiny_labelled) 26 | S3method(apa_print,Anova.mlm) 27 | S3method(apa_print,BFBayesFactor) 28 | S3method(apa_print,BFBayesFactorTop) 29 | S3method(apa_print,afex_aov) 30 | S3method(apa_print,anova) 31 | S3method(apa_print,anova.lme) 32 | S3method(apa_print,aov) 33 | S3method(apa_print,aovlist) 34 | S3method(apa_print,default) 35 | S3method(apa_print,emmGrid) 36 | S3method(apa_print,glht) 37 | S3method(apa_print,glm) 38 | S3method(apa_print,htest) 39 | S3method(apa_print,list) 40 | S3method(apa_print,lm) 41 | S3method(apa_print,lme) 42 | S3method(apa_print,lsmobj) 43 | S3method(apa_print,manova) 44 | S3method(apa_print,merMod) 45 | S3method(apa_print,mixed) 46 | S3method(apa_print,papaja_wsci) 47 | S3method(apa_print,summary.Anova.mlm) 48 | S3method(apa_print,summary.aov) 49 | S3method(apa_print,summary.aovlist) 50 | S3method(apa_print,summary.glht) 51 | S3method(apa_print,summary.glm) 52 | S3method(apa_print,summary.lm) 53 | S3method(apa_print,summary.manova) 54 | S3method(apa_print,summary.ref.grid) 55 | S3method(apa_print,summary_emm) 56 | S3method(apa_table,apa_results) 57 | S3method(apa_table,apa_results_table) 58 | S3method(apa_table,data.frame) 59 | S3method(apa_table,default) 60 | S3method(apa_table,list) 61 | S3method(apa_table,matrix) 62 | S3method(apa_violinplot,afex_aov) 63 | S3method(apa_violinplot,default) 64 | S3method(beautify_terms,character) 65 | S3method(beautify_terms,data.frame) 66 | S3method(beautify_terms,factor) 67 | S3method(beautify_terms,numeric) 68 | S3method(print,apa_results_table) 69 | S3method(sanitize_terms,character) 70 | S3method(sanitize_terms,data.frame) 71 | S3method(sanitize_terms,factor) 72 | S3method(sanitize_terms,list) 73 | S3method(summary,papaja_wsci) 74 | S3method(transmute_df_into_label,apa_results) 75 | S3method(transmute_df_into_label,apa_results_table) 76 | export(add_equals) 77 | export(add_glue_to_apa_results) 78 | export(apa6_doc) 79 | export(apa6_docx) 80 | export(apa6_pdf) 81 | export(apa6_word) 82 | export(apa_barplot) 83 | export(apa_beeplot) 84 | export(apa_confint) 85 | export(apa_df) 86 | export(apa_factorial_plot) 87 | export(apa_hdint) 88 | export(apa_interval) 89 | export(apa_lineplot) 90 | export(apa_num) 91 | export(apa_p) 92 | export(apa_prepare_doc) 93 | export(apa_print) 94 | export(apa_table) 95 | export(apa_violinplot) 96 | export(beautify_terms) 97 | export(ci) 98 | export(cite_r) 99 | export(conf.int) 100 | export(conf_int) 101 | export(create_bib) 102 | export(df_into_label) 103 | export(fetch_web_refs) 104 | export(generate_author_yml) 105 | export(glue_apa_results) 106 | export(in_paren) 107 | export(print_confint) 108 | export(print_df) 109 | export(print_hdint) 110 | export(print_interval) 111 | export(print_num) 112 | export(print_p) 113 | export(printnum) 114 | export(printp) 115 | export(quote_from_tex) 116 | export(r_refs) 117 | export(remove_comments) 118 | export(render_appendix) 119 | export(revision_letter_pdf) 120 | export(sanitize_terms) 121 | export(se) 122 | export(simple_codebook) 123 | export(sort_terms) 124 | export(theme_apa) 125 | export(transmute_df_into_label) 126 | export(within_subjects_conf_int) 127 | export(wsci) 128 | import(grDevices) 129 | import(graphics) 130 | import(tinylabels) 131 | importFrom(methods,is) 132 | importFrom(stats,formula) 133 | importFrom(stats,median) 134 | importFrom(stats,setNames) 135 | importFrom(stats,terms) 136 | -------------------------------------------------------------------------------- /R/add_custom_effect_sizes.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | 3 | add_custom_effect_sizes <- function(estimate, ...) { 4 | UseMethod("add_custom_effect_sizes", estimate) 5 | } 6 | 7 | #' @keywords internal 8 | 9 | add_custom_effect_sizes.character <- function(estimate, canonical_table, .x = NULL, ...) { 10 | 11 | if(length(estimate) > 1L) warning("Calculating more than one effect-size measure is now deprecated. Only the first one will be calculated.") 12 | estimate <- estimate[[1L]] 13 | 14 | add_effect_sizes(x = canonical_table, es = estimate, ...) 15 | } 16 | 17 | #' @keywords internal 18 | 19 | add_custom_effect_sizes.data.frame <- function(estimate, canonical_table, intercept = FALSE, ...) { 20 | 21 | if(!intercept) canonical_table <- canonical_table[canonical_table$term != "(Intercept)", , drop = FALSE] 22 | 23 | y <- merge( 24 | x = canonical_table 25 | , y = tidy_es(estimate) 26 | , sort = FALSE 27 | , all.x = TRUE # Do not drop terms from main results object 28 | ) 29 | 30 | if(anyNA(y)) { 31 | warning("Custom effect sizes were not available for some model terms. These have been dropped from the output object.", call. = FALSE) 32 | y <- stats::na.omit(y) 33 | } 34 | y 35 | } 36 | 37 | #' @keywords internal 38 | 39 | add_custom_effect_sizes.function <- function(estimate, canonical_table, intercept = FALSE, .x = NULL, observed = NULL, ...) { 40 | 41 | if(is.null(.x)) stop("Cannot apply custom effect-size function to this class of object.", call. = FALSE) 42 | 43 | estimate_formals <- names(formals(estimate)) 44 | 45 | estimate_args <- list( 46 | .x 47 | ) 48 | 49 | if(length(observed)) { 50 | if(any(estimate_formals == "observed")) estimate_args$observed <- observed 51 | if(any(estimate_formals == "generalized")) estimate_args$generalized <- observed 52 | 53 | # warnings 54 | if(!any(estimate_formals == "observed") & !any(estimate_formals == "generalized")) { 55 | warning( 56 | "Some terms have been specified as being observed, but the provided effect-size function does not seem to support observed terms." 57 | , call. = FALSE 58 | ) 59 | } 60 | } 61 | 62 | if(isTRUE(intercept) & any(estimate_formals == "include_intercept")) { 63 | estimate_args$include_intercept <- TRUE 64 | message("Turning on intercept") 65 | } 66 | 67 | 68 | add_custom_effect_sizes( 69 | estimate = do.call(what = estimate, args = estimate_args) 70 | , canonical_table = canonical_table 71 | , .x = .x 72 | , ... 73 | ) 74 | } 75 | -------------------------------------------------------------------------------- /R/apa_barplot.R: -------------------------------------------------------------------------------- 1 | #' Bar Plots for Factorial Designs that Conform to APA Guidelines 2 | #' 3 | #' Create one or more bar plots from a `data.frame` containing data from 4 | #' a factorial design and set APA-friendly defaults. 5 | #' 6 | #' @inherit apa_factorial_plot 7 | #' @param ... Further arguments passed on to [apa_factorial_plot()]. 8 | #' @family plots for factorial designs 9 | #' 10 | #' @examples 11 | #' 12 | #' apa_barplot( 13 | #' data = npk 14 | #' , id = "block" 15 | #' , dv = "yield" 16 | #' , factors = c("N") 17 | #' ) 18 | #' 19 | #' apa_barplot( 20 | #' data = npk 21 | #' , id = "block" 22 | #' , dv = "yield" 23 | #' , factors = c("N", "P") 24 | #' ) 25 | #' 26 | #' apa_barplot( 27 | #' data = npk 28 | #' , id = "block" 29 | #' , dv = "yield" 30 | #' , factors = c("N", "P", "K") 31 | #' , ylim = c(0, 80) 32 | #' , level = .34 33 | #' , las = 1 34 | #' ) 35 | #' 36 | #' @import grDevices 37 | #' @import graphics 38 | #' @rdname apa_barplot 39 | #' @export 40 | 41 | apa_barplot <- function(data, ...){ 42 | UseMethod("apa_barplot", data) 43 | } 44 | 45 | #' @rdname apa_barplot 46 | #' @export 47 | 48 | apa_barplot.default <- function( 49 | data 50 | , id 51 | , factors = NULL 52 | , dv 53 | , tendency = mean 54 | , dispersion = conf_int 55 | , level = 0.95 56 | , fun_aggregate = mean 57 | , na.rm = TRUE 58 | , use = "all.obs" 59 | , reference = 0 60 | , intercept = NULL 61 | , args_x_axis = NULL 62 | , args_y_axis = NULL 63 | , args_title = NULL 64 | , args_rect = NULL 65 | , args_error_bars = NULL 66 | , args_legend = NULL 67 | , xlab = NULL 68 | , ylab = NULL 69 | , main = NULL 70 | , set_par = TRUE 71 | , ... 72 | ){ 73 | ellipsis <- defaults( 74 | list(...) 75 | , set.if.null = list( 76 | data = data 77 | , id = id 78 | , factors = factors 79 | , dv = dv 80 | , tendency = substitute(tendency) 81 | , dispersion = substitute(dispersion) 82 | , level = level 83 | , fun_aggregate = substitute(fun_aggregate) 84 | , na.rm = na.rm 85 | , use = use 86 | , reference = reference 87 | , intercept = intercept 88 | , args_x_axis = args_x_axis 89 | , args_y_axis = args_y_axis 90 | , args_title = args_title 91 | , args_rect = args_rect 92 | , args_error_bars = args_error_bars 93 | , args_legend = args_legend 94 | , xlab = xlab 95 | , ylab = ylab 96 | , main = main 97 | , set_par = set_par 98 | , jit = .4 # add parameter 'space' 99 | , plot = c("bars", "error_bars") 100 | ) 101 | ) 102 | do.call("apa_factorial_plot", ellipsis) 103 | } 104 | 105 | 106 | #' @rdname apa_barplot 107 | #' @export 108 | 109 | apa_barplot.afex_aov <- function( 110 | data 111 | , tendency = mean 112 | , dispersion = conf_int 113 | , fun_aggregate = mean 114 | , ... 115 | ){ 116 | 117 | ellipsis <- list(...) 118 | 119 | ellipsis <- defaults( 120 | ellipsis 121 | , set = list( 122 | "data" = data 123 | , "plot" = c("bars", "error_bars") 124 | , "tendency" = substitute(tendency) 125 | , "dispersion" = substitute(dispersion) 126 | , "fun_aggregate" = substitute(fun_aggregate) 127 | ) 128 | ) 129 | do.call("apa_factorial_plot.afex_aov", ellipsis) 130 | } 131 | -------------------------------------------------------------------------------- /R/apa_beeplot.R: -------------------------------------------------------------------------------- 1 | #' Bee-swarm Plots for Factorial Designs that Conform to APA Guidelines 2 | #' 3 | #' Create one or more beeswarm plots from a `data.frame` containing data from 4 | #' a factorial design and set APA-friendly defaults. 5 | #' 6 | #' @inherit apa_factorial_plot 7 | #' @param ... Further arguments passed on to [apa_factorial_plot()]. 8 | #' @family plots for factorial designs 9 | #' @examples 10 | #' apa_beeplot( 11 | #' data = npk 12 | #' , id = "block" 13 | #' , dv = "yield" 14 | #' , factors = c("N") 15 | #' ) 16 | #' 17 | #' apa_beeplot( 18 | #' data = npk 19 | #' , id = "block" 20 | #' , dv = "yield" 21 | #' , factors = c("N", "P") 22 | #' , args.legend = list(x = "center") 23 | #' ) 24 | #' 25 | #' apa_beeplot( 26 | #' data = npk 27 | #' , id = "block" 28 | #' , dv = "yield" 29 | #' , factors = c("N", "P", "K") 30 | #' , ylim = c(0, 80) 31 | #' , level = .34 32 | #' , las = 1 33 | #' ) 34 | #' 35 | #' @import grDevices 36 | #' @import graphics 37 | #' @rdname apa_beeplot 38 | #' @export 39 | 40 | apa_beeplot <- function(data, ...) { 41 | UseMethod("apa_beeplot", data) 42 | } 43 | 44 | 45 | #' @rdname apa_beeplot 46 | #' @export 47 | 48 | apa_beeplot.default <- function( 49 | data 50 | , id 51 | , factors = NULL 52 | , dv 53 | , tendency = mean 54 | , dispersion = conf_int 55 | , level = 0.95 56 | , fun_aggregate = mean 57 | , na.rm = TRUE 58 | , use = "all.obs" 59 | , intercept = NULL 60 | , args_x_axis = NULL 61 | , args_y_axis = NULL 62 | , args_title = NULL 63 | , args_points = NULL 64 | , args_swarm = NULL 65 | , args_error_bars = NULL 66 | , args_legend = NULL 67 | , jit = .3 68 | , xlab = NULL 69 | , ylab = NULL 70 | , main = NULL 71 | , set_par = TRUE 72 | , ... 73 | ){ 74 | ellipsis <- defaults( 75 | list(...) 76 | , set.if.null =list( 77 | data = data 78 | , id = id 79 | , factors = factors 80 | , dv = dv 81 | , tendency = substitute(tendency) 82 | , dispersion = substitute(dispersion) 83 | , level = level 84 | , fun_aggregate = substitute(fun_aggregate) 85 | , na.rm = na.rm 86 | , use = use 87 | , intercept = intercept 88 | , args_x_axis = args_x_axis 89 | , args_y_axis = args_y_axis 90 | , args_points = args_points 91 | , args_swarm = args_swarm 92 | , args_error_bars = args_error_bars 93 | , args_legend = args_legend 94 | , jit = jit 95 | , xlab = xlab 96 | , ylab = ylab 97 | , main = main 98 | , set_par = set_par 99 | , plot = c("points", "error_bars", "swarms") 100 | ) 101 | ) 102 | do.call("apa_factorial_plot", ellipsis) 103 | } 104 | 105 | 106 | #' @rdname apa_beeplot 107 | #' @export 108 | 109 | apa_beeplot.afex_aov <- function( 110 | data 111 | , tendency = mean 112 | , dispersion = conf_int 113 | , fun_aggregate = mean 114 | , ... 115 | ){ 116 | 117 | ellipsis <- list(...) 118 | 119 | ellipsis <- defaults( 120 | ellipsis 121 | , set = list( 122 | "data" = data 123 | , "plot" = c("swarms", "error_bars", "points") 124 | , "tendency" = substitute(tendency) 125 | , "dispersion" = substitute(dispersion) 126 | , "fun_aggregate" = substitute(fun_aggregate) 127 | ) 128 | ) 129 | do.call("apa_factorial_plot.afex_aov", ellipsis) 130 | } 131 | -------------------------------------------------------------------------------- /R/apa_lineplot.R: -------------------------------------------------------------------------------- 1 | #' Line Plots for Factorial Designs that Conform to APA Guidelines 2 | #' 3 | #' Creates one or more line plots from a `data.frame` containing data from 4 | #' a factorial design and set APA-friendly defaults. 5 | #' 6 | #' @inherit apa_factorial_plot 7 | #' 8 | #' @family plots for factorial designs 9 | #' @examples 10 | #' apa_lineplot( 11 | #' data = npk 12 | #' , id = "block" 13 | #' , dv = "yield" 14 | #' , factors = c("N") 15 | #' ) 16 | #' 17 | #' apa_lineplot( 18 | #' data = npk 19 | #' , id = "block" 20 | #' , dv = "yield" 21 | #' , factors = c("N", "P") 22 | #' , args_legend = list(x = "center") 23 | #' , jit = 0 24 | #' ) 25 | #' 26 | #' apa_lineplot( 27 | #' data = npk 28 | #' , id = "block" 29 | #' , dv = "yield" 30 | #' , factors = c("N", "P", "K") 31 | #' , ylim = c(0, 80) 32 | #' , level = .34 33 | #' , las = 1 34 | #' ) 35 | #' 36 | #' @param ... Further arguments passed on to [apa_factorial_plot()]. 37 | #' @import grDevices 38 | #' @import graphics 39 | #' @rdname apa_lineplot 40 | #' @export 41 | 42 | apa_lineplot <- function(data, ...){ 43 | UseMethod("apa_lineplot", data) 44 | } 45 | 46 | 47 | #' @rdname apa_lineplot 48 | #' @export 49 | 50 | apa_lineplot.default <- function( 51 | data 52 | , id 53 | , factors = NULL 54 | , dv 55 | , tendency = mean 56 | , dispersion = conf_int 57 | , level = 0.95 58 | , fun_aggregate = mean 59 | , na.rm = TRUE 60 | , use = "all.obs" 61 | , intercept = NULL 62 | , args_x_axis = NULL 63 | , args_y_axis = NULL 64 | , args_title = NULL 65 | , args_points = NULL 66 | , args_lines = NULL 67 | , args_error_bars = NULL 68 | , args_legend = NULL 69 | , jit = .3 70 | , xlab = NULL 71 | , ylab = NULL 72 | , main = NULL 73 | , set_par = TRUE 74 | , ... 75 | ){ 76 | ellipsis <- defaults( 77 | list(...) 78 | , set.if.null =list( 79 | data = data 80 | , id = id 81 | , factors = factors 82 | , dv = dv 83 | , tendency = substitute(tendency) 84 | , dispersion = substitute(dispersion) 85 | , level = level 86 | , fun_aggregate = substitute(fun_aggregate) 87 | , na.rm = na.rm 88 | , use = use 89 | , intercept = intercept 90 | , args_x_axis = args_x_axis 91 | , args_y_axis = args_y_axis 92 | , args_points = args_points 93 | , args_lines = args_lines 94 | , args_error_bars = args_error_bars 95 | , args_legend = args_legend 96 | , jit = jit 97 | , xlab = xlab 98 | , ylab = ylab 99 | , main = main 100 | , set_par = set_par 101 | , plot = c("points", "error_bars", "lines") 102 | ) 103 | ) 104 | do.call("apa_factorial_plot", ellipsis) 105 | } 106 | 107 | #' @rdname apa_lineplot 108 | #' @export 109 | 110 | apa_lineplot.afex_aov <- function( 111 | data 112 | , tendency = mean 113 | , dispersion = conf_int 114 | , fun_aggregate = mean 115 | , ... 116 | ){ 117 | 118 | ellipsis <- list(...) 119 | 120 | ellipsis <- defaults( 121 | ellipsis 122 | , set = list( 123 | "data" = data 124 | , "plot" = c("lines", "error_bars", "points") 125 | , "tendency" = substitute(tendency) 126 | , "dispersion" = substitute(dispersion) 127 | , "fun_aggregate" = substitute(fun_aggregate) 128 | ) 129 | ) 130 | do.call("apa_factorial_plot.afex_aov", ellipsis) 131 | } 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /R/apa_print.R: -------------------------------------------------------------------------------- 1 | #' Typeset Statistical Results 2 | #' 3 | #' A generic function that takes objects from various statistical methods to 4 | #' create formatted character strings to report the results in accordance with 5 | #' APA manuscript guidelines. The function invokes particular methods, which 6 | #' depend on the \code{\link{class}} of the first argument. 7 | #' 8 | #' @param x A model object. 9 | #' @param ... Additional arguments passed to methods. 10 | #' 11 | #' @evalRd apa_results_return_value() 12 | #' 13 | #' @family apa_print 14 | #' @examples 15 | #' # List methods for apa_print() 16 | #' methods("apa_print") 17 | #' @export 18 | 19 | apa_print <- function(x, ...) { 20 | UseMethod("apa_print", x) 21 | } 22 | 23 | 24 | # #' @importClassesFrom BayesFactor BFBayesFactor 25 | # setGeneric("apa_print") 26 | 27 | #' @method apa_print default 28 | #' @export 29 | 30 | apa_print.default <- function(x, ...) no_method(x) 31 | -------------------------------------------------------------------------------- /R/apa_print_manova.R: -------------------------------------------------------------------------------- 1 | 2 | #' @param test Character. For MANOVA, the multivariate test statistic to be 3 | #' reported, see \code{\link[stats]{summary.manova}}. 4 | #' @inheritParams glue_apa_results 5 | #' @rdname apa_print.aov 6 | #' @method apa_print manova 7 | #' @export 8 | 9 | apa_print.manova <- function(x, test = "Pillai", in_paren = FALSE, ...) { 10 | summ_x <- summary(x, test = test) 11 | apa_print(summ_x, in_paren = in_paren, ...) 12 | } 13 | 14 | #' @inheritParams glue_apa_results 15 | #' @rdname apa_print.aov 16 | #' @method apa_print summary.manova 17 | #' @export 18 | 19 | apa_print.summary.manova <- function(x, in_paren = FALSE, ...) { 20 | 21 | validate(in_paren, check_class = "logical", check_length = 1L) 22 | 23 | resid_row <- apply(X = x$stats, MARGIN = 1L, anyNA) 24 | 25 | df <- data.frame( 26 | x$stats[!resid_row, , drop = FALSE] 27 | , stringsAsFactors = FALSE 28 | ) 29 | df$Effect <- rownames(df) 30 | # df$multivariate.df <- df$Df 31 | # df$multivariate.df.residual <- x$stats[resid_row, "Df"] 32 | df$Df <- NULL 33 | 34 | canonical_table <- canonize(df) 35 | beautiful_table <- beautify(canonical_table, ...) 36 | 37 | glue_apa_results( 38 | beautiful_table 39 | , est_glue = construct_glue(beautiful_table, "estimate") 40 | , stat_glue = construct_glue(beautiful_table, "statistic") 41 | , in_paren = in_paren 42 | , simplify = FALSE 43 | ) 44 | } 45 | -------------------------------------------------------------------------------- /R/apa_print_wsci.R: -------------------------------------------------------------------------------- 1 | #' Typeset Within-Subjects Confidence Intervals 2 | #' 3 | #' This method takes an output object from \code{\link{wsci}} and creates a 4 | #' table and character strings to report means and within-subjects confidence 5 | #' intervals in a table or in text. 6 | #' 7 | #' @param x An object of class \code{papaja_wsci}. 8 | #' @inheritDotParams apa_num.numeric 9 | #' 10 | #' @evalRd apa_results_return_value() 11 | #' 12 | #' @method apa_print papaja_wsci 13 | #' @export 14 | 15 | apa_print.papaja_wsci <- function(x, ...) { 16 | 17 | # Note: Parameter 'in_paren' is not necessary (estimate only contains brackets, these are not changed when placed in parentheses) 18 | 19 | summary_wsci <- summary(x) 20 | 21 | res <- init_apa_results() 22 | 23 | res$estimate <- as.list( 24 | paste0( 25 | "$M = " 26 | , apa_num(summary_wsci$mean, ...) 27 | , "$, " 28 | , apa_confint( 29 | x = summary_wsci[, c("lower_limit", "upper_limit")] 30 | , conf.int = attr(x, "Confidence level") 31 | , enclose_math = TRUE 32 | , ... 33 | ) 34 | ) 35 | ) 36 | 37 | factors <- setdiff(colnames(summary_wsci), c("mean", "lower_limit", "upper_limit")) 38 | 39 | args <- list() 40 | for(i in factors) { 41 | args[[i]] <- paste0(i, summary_wsci[[i]]) 42 | } 43 | args$sep = "_" 44 | 45 | names(res$estimate) <- do.call("paste", args) # TODO: add names consistent with other methods (especially emm) 46 | 47 | # res$full_result <- res$estimate 48 | 49 | res$table <- summary_wsci[, factors, drop = FALSE] 50 | for(i in factors) { 51 | res$table[[i]] <- as.character(res$table[[i]], keep_label = TRUE) 52 | } 53 | 54 | res$table$estimate <- apa_num(summary_wsci$mean, ...) 55 | res$table$conf.int <- unlist( 56 | apa_interval( 57 | summary_wsci[, c("lower_limit", "upper_limit"), drop = FALSE] 58 | , interval_type = NULL # suppresses leading NA% CI 59 | , ... 60 | ) 61 | ) 62 | 63 | variable_labels(res$table) <- c( 64 | estimate = "$M$" 65 | , conf.int = paste0(attr(x, "Confidence level") * 100, "\\% CI") 66 | ) 67 | 68 | res$table <- default_label(res$table) # add labels for factors 69 | 70 | class(res$table) <- c("apa_results_table", "data.frame") 71 | # return 72 | res 73 | } 74 | 75 | -------------------------------------------------------------------------------- /R/apa_violinplot.R: -------------------------------------------------------------------------------- 1 | #' Violin Plots for Factorial Designs that Conform to APA Guidelines 2 | #' 3 | #' Creates one or more violin plots from a `data.frame` containing data from 4 | #' a factorial design and sets APA-friendly defaults. 5 | #' 6 | #' @inherit apa_factorial_plot 7 | #' @param ... Further arguments passed on to [apa_factorial_plot()]. 8 | #' 9 | #' @family plots for factorial designs 10 | #' @examples 11 | #' apa_violinplot( 12 | #' data = npk 13 | #' , id = "block" 14 | #' , dv = "yield" 15 | #' , factors = c("N") 16 | #' ) 17 | #' 18 | #' apa_violinplot( 19 | #' data = npk 20 | #' , id = "block" 21 | #' , dv = "yield" 22 | #' , factors = c("N", "P") 23 | #' , args_legend = list(x = "center") 24 | #' , jit = 0.1 25 | #' ) 26 | #' 27 | #' 28 | #' @import grDevices 29 | #' @import graphics 30 | #' @rdname apa_violinplot 31 | #' @export 32 | 33 | apa_violinplot <- function(data, ...){ 34 | UseMethod("apa_violinplot", data) 35 | } 36 | 37 | 38 | 39 | #' @rdname apa_violinplot 40 | #' @export 41 | 42 | apa_violinplot.default <- function( 43 | data 44 | , id 45 | , factors = NULL 46 | , dv 47 | , tendency = mean 48 | , dispersion = conf_int 49 | , level = 0.95 50 | , fun_aggregate = mean 51 | , na.rm = TRUE 52 | , use = "all.obs" 53 | , intercept = NULL 54 | , args_x_axis = NULL 55 | , args_y_axis = NULL 56 | , args_title = NULL 57 | , args_points = NULL 58 | , args_lines = NULL 59 | , args_error_bars = NULL 60 | , args_legend = NULL 61 | , jit = .3 62 | , xlab = NULL 63 | , ylab = NULL 64 | , main = NULL 65 | , ... 66 | ){ 67 | ellipsis <- defaults( 68 | list(...) 69 | , set.if.null =list( 70 | data = data 71 | , id = id 72 | , factors = factors 73 | , dv = dv 74 | , tendency = substitute(tendency) 75 | , dispersion = substitute(dispersion) 76 | , level = level 77 | , fun_aggregate = substitute(fun_aggregate) 78 | , na.rm = na.rm 79 | , use = use 80 | , intercept = intercept 81 | , args_x_axis = args_x_axis 82 | , args_y_axis = args_y_axis 83 | , args_points = args_points 84 | , args_lines = args_lines 85 | , args_error_bars = args_error_bars 86 | , args_legend = args_legend 87 | , jit = jit 88 | , xlab = xlab 89 | , ylab = ylab 90 | , main = main 91 | , plot = c("points", "violins", "error_bars") 92 | ) 93 | ) 94 | do.call("apa_factorial_plot", ellipsis) 95 | } 96 | 97 | #' @rdname apa_violinplot 98 | #' @export 99 | 100 | apa_violinplot.afex_aov <- function( 101 | data 102 | , tendency = mean 103 | , dispersion = conf_int 104 | , fun_aggregate = mean 105 | , ... 106 | ){ 107 | 108 | ellipsis <- list(...) 109 | 110 | ellipsis <- defaults( 111 | ellipsis 112 | , set = list( 113 | data = data 114 | , plot = c("points", "violins", "error_bars") 115 | , tendency = substitute(tendency) 116 | , dispersion = substitute(dispersion) 117 | , fun_aggregate = substitute(fun_aggregate) 118 | ) 119 | ) 120 | do.call("apa_factorial_plot.afex_aov", ellipsis) 121 | } 122 | -------------------------------------------------------------------------------- /R/fast_aggregate.R: -------------------------------------------------------------------------------- 1 | #' Aggregate data much faster using dplyr 2 | #' 3 | #' This is a convenience wrapper for aggregating your data using \pkg{dplyr} functions that tend to be much faster than the 4 | #' usual [stats::aggregate()] command. It is also easy to call from within a function. *This function is not exported.* 5 | #' 6 | #' @param data A `data.frame` that contains the data. 7 | #' @param factors Character. A vector of factor names to aggregate data by. 8 | #' @param dv Character. The dependent variable to aggregate. All variables in `data` that contain this character string 9 | #' will be aggregated separately. 10 | #' @param fun Closure. The function used for aggregation. 11 | #' @keywords internal 12 | 13 | fast_aggregate <- function(data, factors, dv, fun, na.rm = TRUE) { 14 | # subset: this is a bit faster than subset.data.frame 15 | data <- data[, colnames(data) %in% c(factors, dv)] 16 | # the dplyr magic: this construct seems to be as fast as using pipes 17 | grouped <- dplyr::grouped_df(data, vars = factors, drop = TRUE) 18 | 19 | dv_ <- dplyr::sym(dv) 20 | args <- list(x = dplyr::quo(!!dv_), na.rm = na.rm) 21 | agg_data <- as.data.frame(dplyr::summarise(.data = grouped, temporary_dv_name = fun(!!!args))) 22 | # do this in base R to avoid using `:=` 23 | colnames(agg_data)[colnames(agg_data) == "temporary_dv_name"] <- dv 24 | 25 | # soft-deprecated in dplyr: 26 | # agg_data <- as.data.frame(dplyr::summarise_all(.tbl = grouped, .funs = dplyr::funs(fun(., na.rm = TRUE)))) 27 | 28 | return(agg_data) 29 | } 30 | 31 | -------------------------------------------------------------------------------- /R/in_paren.R: -------------------------------------------------------------------------------- 1 | #' Replace Parentheses with Brackets 2 | #' 3 | #' Takes a single character or a list of characters and replaces parentheses 4 | #' with brackets. Can be used to prepare a string of statistics (e.g. containing 5 | #' degrees of freedom) for reporting within parentheses. 6 | #' 7 | #' @param x Character. Single character or list of characters. 8 | #' @return An object of the same type as `x`, where all parentheses have been 9 | #' replaced by brackets. 10 | #' 11 | #' @seealso [apa_print()] 12 | #' @examples 13 | #' t_stat <- t.test(extra ~ group, data = sleep) 14 | #' t_test_res <- apa_print(t_stat) 15 | #' in_paren(t_test_res$stat) 16 | #' in_paren(t_test_res[1:3]) 17 | #' @export 18 | 19 | in_paren <- function(x) { 20 | if(is.list(x)) { 21 | lapply( 22 | X = x 23 | , FUN = function(x) { 24 | gsub( 25 | gsub(x, pattern = "(", replacement = "[", fixed = TRUE) 26 | , pattern = ")", replacement = "]", fixed = TRUE 27 | ) 28 | } 29 | ) 30 | } else { 31 | gsub( 32 | gsub(x, pattern = "(", replacement = "[", fixed = TRUE) 33 | , pattern = ")", replacement = "]", fixed = TRUE 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /R/onload.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname, pkgname) { # nocov start 2 | if(length(knitr::opts_knit$get("rmarkdown.pandoc.to")) > 0 && !is.null(rmarkdown::metadata$lang)) { 3 | lang <- parse_bcp47(rmarkdown::metadata$lang) 4 | } else { 5 | lang <- "english" 6 | } 7 | 8 | op <- options() 9 | op_papaja <- list( 10 | # papaja.language = lang 11 | papaja.terms = localize(lang) 12 | , papaja.na_string = "NA" 13 | , papaja.plot_colors = "greyscale" 14 | , papaja.mse = !package_available("effectsize") 15 | , papaja.sphericity_correction = "GG" 16 | ) 17 | 18 | if(package_available("effectsize")) { 19 | effectsize_eta_squared <- function(x, observed = NULL, include_intercept = FALSE, ...) { 20 | 21 | if(is.null(observed)) { 22 | generalized <- character(0L) 23 | } else { 24 | generalized <- observed 25 | } 26 | 27 | effectsize::eta_squared( 28 | x 29 | , generalized = generalized 30 | , include_intercept = include_intercept 31 | , ... 32 | ) 33 | } 34 | 35 | op_papaja$papaja.estimate_anova <- effectsize_eta_squared 36 | 37 | # Revert to using a two-sided 90% CI to provide additional information for 38 | # testing minimal effects (Steiger, 2004). 39 | if(utils::packageVersion("effectsize") >= "0.5") { 40 | op_papaja$papaja.estimate_anova <- function( 41 | ... 42 | , observed = NULL 43 | , include_intercept = FALSE 44 | , alternative = "two.sided" 45 | , ci = 0.9 46 | ) { 47 | effectsize_eta_squared( 48 | ... 49 | , observed = observed 50 | , alternative = alternative 51 | , ci = ci 52 | , include_intercept = include_intercept 53 | ) 54 | } 55 | } 56 | 57 | # A fallback option should be specified in the function definition via 58 | # getOption("papaja.estimate_anova", default = "ges"), which ensures that 59 | # the default is available even if papaja is not loaded. 60 | } 61 | 62 | 63 | toset <- !(names(op_papaja) %in% names(op)) 64 | if(any(toset)) options(op_papaja[toset]) 65 | 66 | 67 | # Fix dplyr R CMD Check note 68 | if(getRversion() >= "2.15.1") utils::globalVariables(c(".")) 69 | 70 | invisible() 71 | } # nocov end 72 | -------------------------------------------------------------------------------- /R/papaja.R: -------------------------------------------------------------------------------- 1 | #' Prepare APA Journal Articles with R Markdown 2 | #' 3 | #' `papaja` is an [award-winning](https://improvingpsych.org/mission/awards/) R package that facilitates creating computationally reproducible, submission-ready manuscripts which conform to the American Psychological Association (APA) manuscript guidelines (6th Edition). 4 | #' 5 | #' @details 6 | #' 7 | #' `papaja` provides 8 | #' 9 | #' - an [R Markdown](https://rmarkdown.rstudio.com/) template that can be used with (or without) [RStudio](https://posit.co/) to create PDF documents (using the [apa6](https://ctan.org/pkg/apa6) LaTeX class) or Word documents (using a .docx-reference file). 10 | #' - Functions to *typeset* the results from *statistical analyses* (e.g., [apa_print()]), 11 | #' - functions to create *tables* ([apa_table()]), and 12 | #' - functions to create *figures* in accordance with APA guidelines (e.g., [apa_factorial_plot()]). 13 | #' 14 | #' @section System requirements: 15 | #' To use `papaja` you need either an up-to-date version of 16 | #' [RStudio](https://posit.co/) or 17 | #' [pandoc](https://pandoc.org/). If you want to create PDF- 18 | #' in addition to DOCX-documents you additionally need a 19 | #' [TeX](https://en.wikipedia.org/wiki/TeX) distribution. We recommend 20 | #' [TinyTex](https://yihui.org/tinytex/), which can be installed from within 21 | #' R via the \pkg{tinytex} package. 22 | #' 23 | #' Please refer to the [`papaja` manual](https://frederikaust.com/papaja_man/introduction.html#getting-started) 24 | #' for detailed installation instructions. 25 | #' 26 | #' @section Getting help: 27 | #' For a comprehensive introduction to `papaja`, see the current draft of the [manual](https://frederikaust.com/papaja_man/). 28 | #' If you have a specific question that is not answered in the manual, feel free to ask a question on Stack Overflow [using the `papaja` tag](https://stackoverflow.com/questions/tagged/papaja). 29 | #' If you believe you have found a bug or would like to request a new feature, [open an issue](https://github.com/crsh/papaja/issues) on Github and provide a [minimal complete verifiable example](https://stackoverflow.com/help/minimal-reproducible-example). 30 | #' 31 | #' @section Authors: 32 | #' Frederik Aust (frederik.aust at uni-koeln.de). 33 | #' Marius Barth (marius.barth at uni-koeln.de). 34 | #' @section Maintainer: 35 | #' Frederik Aust (frederik.aust at uni-koeln.de). 36 | #' 37 | #' @docType package 38 | #' @name papaja 39 | 40 | "_PACKAGE" 41 | -------------------------------------------------------------------------------- /R/remove_comments.R: -------------------------------------------------------------------------------- 1 | #' Remove Comments 2 | #' 3 | #' Removes markdown comments from an R Markdown file. 4 | #' 5 | #' @param x Character. Path to an R Markdown file. 6 | #' @param file Character. Name of the new R Markdown file without comments. 7 | #' @return No return value, called to write text to `file`. 8 | #' @export 9 | 10 | remove_comments <- function(x, file) { 11 | 12 | x <- readLines_utf8(x) 13 | x <- x[!grepl("^).)+-->$", x, useBytes = TRUE, perl = TRUE)] 14 | x <- x[!grepl("^<@~\\{#.+\\}$", x, useBytes = TRUE)] 15 | x <- x[!grepl("^~@>$", x, useBytes = TRUE)] 16 | 17 | x <- gsub(").+)-->", "", x, useBytes = TRUE, perl = TRUE) 18 | 19 | writeLines(x, con = file, useBytes = TRUE) 20 | } 21 | -------------------------------------------------------------------------------- /R/tidy_es.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | 3 | tidy_es <- function(x) { 4 | UseMethod("tidy_es", x) 5 | } 6 | 7 | #' @keywords internal 8 | 9 | tidy_es.default <- function(x) { 10 | tryCatch( 11 | broom::tidy(x) 12 | , error = function(e) { 13 | stop("The object returned by the function passed to 'es' could not be tidied, that is converted to a data.frame with columns 'estimate', 'conf.low', and 'conf.high'. Please supply a function that returns a data.frame of this structure or pass such a data.frame directly.") 14 | } 15 | ) 16 | } 17 | 18 | #' @keywords internal 19 | 20 | tidy_es.data.frame <- function(x) { 21 | es_cols <- colnames(x) 22 | if( 23 | !"estimate" %in% es_cols | 24 | !"conf.low" %in% es_cols | 25 | !"conf.high" %in% es_cols 26 | ) { 27 | stop("Effect size data.frame must contain the colums 'estimate', 'conf.low', and 'conf.high'") 28 | } 29 | 30 | x 31 | } 32 | 33 | #' @keywords internal 34 | 35 | tidy_es.effectsize_table <- function(x) { 36 | 37 | x <- as.data.frame(x, stringsAsFactors = FALSE) 38 | x$conf.int <- apply(X = x[, c("CI_low", "CI_high"), drop = FALSE], MARGIN = 1L, FUN = list) 39 | x$conf.int <- lapply(X = x$conf.int, unlist) 40 | attr(x$conf.int, "conf.level") <- unique(x$CI) 41 | x$Effect <- x$Parameter 42 | x$CI_low <- x$CI_high <- x$CI <- x$Parameter <- x$Group <- NULL 43 | canonize(x) 44 | } 45 | 46 | #' @keywords internal 47 | 48 | tidy_es.parameters_model <- function(x) { 49 | tidy_es.effectsize_table(x) 50 | } 51 | 52 | #' @keywords internal 53 | 54 | tidy_es.parameters_distribution <- function(x) { 55 | tidy_es.effectsize_table(x) 56 | } 57 | -------------------------------------------------------------------------------- /R/transmute_df_into_label.R: -------------------------------------------------------------------------------- 1 | 2 | #' Transmute Degrees-of-Freedom Columns into Variable Labels 3 | #' 4 | #' Takes the output from [apa_print()] methods and modifies the results table 5 | #' by transmuting information about degrees of freedom into the variable labels of 6 | #' test-statistic columns. 7 | #' 8 | #' @param x Either the complete output object created by [apa_print()] methods, 9 | #' or the `table` component of such objects. 10 | #' @param check_df Logical. If TRUE (the default), checks if degrees-of-freedom-columns contain non-integer values. 11 | #' @param ... further arguments passed from an to other methods 12 | #' 13 | #' @return An object of the same class as `x`, where a redundant column with 14 | #' degrees of freedom has been incorporated into the column label of the column 15 | #' `statistic`. 16 | #' 17 | #' @examples 18 | #' apa_out <- apa_print(aov(yield ~ N * P, npk)) 19 | #' 20 | #' # Standard output with separate columns for degrees of freedom: 21 | #' apa_out$table 22 | #' 23 | #' # Modified output where degrees of freedom are incorporated into the variable 24 | #' # label of column 'statistic': 25 | #' transmute_df_into_label(apa_out)$table 26 | #' 27 | #' 28 | #' @rdname transmute_df_into_label 29 | #' @export 30 | 31 | transmute_df_into_label <- function(x, check_df = TRUE, ...) { 32 | UseMethod("transmute_df_into_label") 33 | } 34 | 35 | #' @rdname transmute_df_into_label 36 | #' @export 37 | 38 | df_into_label <- transmute_df_into_label 39 | 40 | #' @rdname transmute_df_into_label 41 | #' @export 42 | transmute_df_into_label.apa_results <- function(x, check_df = TRUE, ...) { 43 | x$table <- transmute_df_into_label(x$table, check_df = check_df, ...) 44 | x 45 | } 46 | 47 | 48 | 49 | #' @rdname transmute_df_into_label 50 | #' @export 51 | 52 | transmute_df_into_label.apa_results_table <- function(x, check_df = TRUE, ...) { 53 | 54 | check_df <- !isFALSE(check_df) # this is more restrictive than isTRUE(check_df) 55 | 56 | if(is.null(x$df) && is.null(x$df.residual)) { 57 | if(check_df) message("There are no df columns to transmute. Returning original input.") 58 | return(x) 59 | } 60 | 61 | unique_names <- unique(lookup_names) 62 | df_columns <- intersect(colnames(x), unique_names[grep(unique_names, pattern = "df", fixed = TRUE)]) 63 | 64 | for (i in df_columns) { 65 | if( length(unique(x[[i]])) > 1L ) { 66 | stop("Cannot transmute columns to variable label:\n Degrees of freedom (in column ", encodeString(i, quote = "'"), ") vary across table rows.", call. = FALSE) 67 | } 68 | } 69 | 70 | if(check_df) { 71 | for (i in df_columns) { 72 | if( length(x[[i]]) > 1L && any(as.numeric(x[[i]]) %% 1 != 0) ) { 73 | warning("Column 'df' contains non-integer values. Please check if these values are really equal to each other before fusing them.") 74 | } 75 | } 76 | } 77 | 78 | tinylabels::variable_label(x$statistic) <- paste0( 79 | "$" 80 | , strip_math_tags(tinylabels::variable_label(x$statistic)) 81 | , "(" 82 | , paste(c(x$df[[1L]], x$df.residual[[1L]]), collapse = ", ") 83 | , ")$" 84 | ) 85 | if(any(colnames(x) == "multivariate.statistic")) { 86 | tinylabels::variable_label(x$multivariate.statistic) <- paste0( 87 | "$" 88 | , strip_math_tags(tinylabels::variable_label(x$multivariate.statistic)) 89 | , "(" 90 | , paste(c(x$multivariate.df[[1L]], x$multivariate.df.residual[[1L]]), collapse = ", ") 91 | , ")$" 92 | ) 93 | } 94 | 95 | x$df <- x$df.residual <- x$multivariate.df <- x$multivariate.df.residual <- NULL 96 | x 97 | } 98 | -------------------------------------------------------------------------------- /R/utils_docs.R: -------------------------------------------------------------------------------- 1 | apa_results_return_value <- function() { 2 | 3 | prefix <- "\\code{apa_print()}-methods return a named list of class \\code{apa_results} containing the following elements:\n" 4 | 5 | list_elements <- list( 6 | estimate = "One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \\code{NULL}." 7 | , statistic = "One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \\code{NULL}." 8 | , full_result = "One or more character strings comprised `estimate` and `statistic`. A single string is returned in a vector; multiple strings are returned as a named list. " 9 | , table = "A \\code{data.frame} of class \\code{apa_results_table} that contains all elements of \\code{estimate} and \\code{statistics}. This table can be passed to \\code{apa_table()} for reporting." 10 | ) 11 | 12 | list_elements <- paste0("\\item{", names(list_elements), "}{", list_elements, "}") 13 | 14 | post_fix <- "\nColumn names in \\code{apa_results_table} are standardized following the \\href{https://www.tidymodels.org/learn/develop/broom/#glossary}{\\pkg{broom} glossary} (e.g., \\code{term}, \\code{estimate} \\code{conf.int}, \\code{statistic}, \\code{df}, \\code{df.residual}, \\code{p.value}). Additionally, each column is labelled (e.g., \\code{$\\\\hat{\\\\eta}^2_G$} or \\code{$t$}) using the \\pkg{tinylabels} package and these labels are used as column names when an \\code{apa_results_table} is passed to \\code{apa_table()}.\n" 15 | 16 | paste( 17 | "\\value{" 18 | , prefix 19 | , paste(list_elements, collapse = "\n") 20 | , post_fix 21 | , "}" 22 | , sep = "\n" 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /R/utils_plot.R: -------------------------------------------------------------------------------- 1 | #' Brighten up a Color 2 | #' 3 | #' Brighten up a specified color (e.g., the swarm color in [apa_beeplot()]). 4 | #' *This function is not exported.* 5 | #' 6 | #' @param col Colour to be brightened up. Can be anything that is digestible by [col2rgb()]. 7 | #' @param factor Numeric. The rate with which the color channel should be boosted. Must be in the range between 0 and 1. 8 | #' @return A character vector as returned by [rgb()]. 9 | #' @keywords internal 10 | 11 | brighten <- function(col, factor){ 12 | validate(factor, check_range = c(0, 1)) 13 | 14 | old_color <- col2rgb(col, alpha = TRUE) 15 | new_color <- rgb( 16 | red = (old_color["red", ]) + (255 - old_color["red", ])^factor 17 | , green = (old_color["green", ]) + (255 - old_color["green", ])^factor 18 | , blue = (old_color["blue", ]) + (255 - old_color["blue", ])^factor 19 | , maxColorValue = 255 20 | ) 21 | return(new_color) 22 | } 23 | 24 | #' Matrix Method for lines() 25 | #' 26 | #' Internal function for convenient plotting of multiple lines. 27 | #' *This function is not exported.* 28 | #' 29 | #' @keywords internal 30 | 31 | lines.matrix <- function(x, y, type = "l", ...) { 32 | 33 | args <- list(...) 34 | args$type = type 35 | 36 | for (i in 1:ncol(x)){ 37 | args.i <- lapply(X = args, FUN = sel, i) 38 | args.i$x <- x[, i] 39 | args.i$y <- y[, i] 40 | do.call("lines", args.i) 41 | } 42 | } 43 | 44 | #' Matrix Method for points() 45 | #' 46 | #' Internal function for convenient plotting of multiple points. 47 | #' *This function is not exported.* 48 | #' 49 | #' @keywords internal 50 | 51 | points.matrix <- function(x, y, type = "p", ...) { 52 | 53 | args <- list(...) 54 | args$type = type 55 | 56 | for (i in 1:ncol(x)){ 57 | args.i <- lapply(X = args, FUN = sel, i) 58 | args.i$x <- unlist(x[, i]) 59 | args.i$y <- unlist(y[, i]) 60 | do.call("points", args.i) 61 | } 62 | } 63 | 64 | 65 | 66 | #' Combine to Expression 67 | #' 68 | #' We use this internal function to generate expressions that can be used for plotting. Accepts a list of elements that are coerced, 69 | #' currently supported elements are `character`, `expression`, and `character` that contain \code{latex} elements. 70 | #' *This function is not exported.* 71 | #' 72 | #' @param x A `list` that contains all elements that are intended to be coerced into one expression. 73 | #' @return An expression 74 | #' @keywords internal 75 | 76 | combine_plotmath <- function(x){ 77 | 78 | x <- lapply(X = x, FUN = tex_conv) 79 | y <- as.expression(substitute(paste(a, b), list(a = x[[1]], b = x[[2]]))) 80 | 81 | if(length(x)>2){ 82 | for (i in 3:length(x)){ 83 | y <- as.expression(substitute(paste(a, b), list(a = y[[1]], b = x[[i]]))) 84 | } 85 | } 86 | return(y) 87 | } 88 | 89 | 90 | #' @keywords internal 91 | 92 | tex_conv <- function(x, latex2exp = package_available("latex2exp")){ 93 | 94 | if( length(x) ){ 95 | if(!is.expression(x)){ 96 | if(latex2exp){ 97 | latex2exp::TeX(x, output = "expression")[[1]] 98 | } else { 99 | as.expression(x)[[1]] 100 | } 101 | } else{ 102 | x[[1]] 103 | } 104 | } else { 105 | as.expression("")[[1]] 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /R/variable_label.R: -------------------------------------------------------------------------------- 1 | 2 | #' @import tinylabels 3 | NULL 4 | 5 | #' Set Default Variable Labels from Column Names 6 | #' 7 | #' This internal function creates variable labels from the column names of a1 8 | #' data frame. 9 | #' 10 | #' @param x A \code{data.frame} 11 | #' @return Returns a \code{data.frame} with labelled columns. Labels are preserved (if already specified), otherwise generated from column names. 12 | #' @rdname default_label 13 | #' @keywords internal 14 | 15 | default_label <- function(x, ...) { 16 | UseMethod("default_label", x) 17 | } 18 | 19 | 20 | 21 | #' @rdname default_label 22 | #' @keywords internal 23 | 24 | default_label.default <- function(x, ...) no_method(x) 25 | 26 | 27 | 28 | #' @rdname default_label 29 | #' @keywords internal 30 | 31 | default_label.data.frame <- function(x, ...) { 32 | 33 | x_out <- as.data.frame.list( 34 | x = mapply( 35 | FUN = function(y, value) { 36 | if(is.null(variable_label(y))) { 37 | variable_label(y) <- value 38 | } 39 | y 40 | } 41 | , y = x 42 | , value = colnames(x) 43 | , USE.NAMES = TRUE 44 | , SIMPLIFY = FALSE 45 | ) 46 | , check.names = FALSE 47 | , stringsAsFactors = FALSE 48 | , col.names = attr(x, "names") 49 | , row.names = attr(x, "row.names") # `rownames(x)` would coerce to character 50 | ) 51 | attributes(x_out) <- attributes(x) 52 | x_out 53 | } 54 | 55 | 56 | 57 | # ------------------------------------------------------------------------------ 58 | # Functions to generate very simple codebooks 59 | 60 | tidy_variable_lables <- function(x) { 61 | x <- default_label.data.frame(x) 62 | labels <- unlist(variable_labels(x)) 63 | 64 | label_range <- function(y) { 65 | 66 | if(inherits(y, "numeric")) return(paste0("[", min(y, na.rm = TRUE), ", ", max(y, na.rm = TRUE), "]")) 67 | if(inherits(y, "factor")) return(nlevels(y)) 68 | if(inherits(y, "character")) return(length(unique(y[!is.na(y)]))) 69 | 70 | return("") 71 | } 72 | 73 | tidied_labels <- data.frame( 74 | variable = names(labels) 75 | , label = ifelse(labels == names(labels), NA, labels) 76 | , type = sapply(x, function(y) paste(class(y), collapse = ", ")) 77 | , range = sapply(x, label_range) 78 | , missing = sapply(x, function(y) sum(is.na(y))) 79 | , stringsAsFactors = FALSE 80 | ) 81 | 82 | if(isTRUE(package_available("skimr"))) { 83 | tidied_labels <- cbind( 84 | tidied_labels 85 | , distribution = sapply(x, function(y) if (is.numeric(y)) skimr::inline_hist(y) else "") 86 | ) 87 | } 88 | 89 | tidied_labels 90 | } 91 | 92 | 93 | #' Simple Codebook 94 | #' 95 | #' Generate a simple codebook in CSV-format from a (labelled) `data.frame`. 96 | #' 97 | #' @param x data.frame. Data to be documented. 98 | #' @inheritDotParams utils::write.table -x 99 | #' 100 | #' @details If the \pkg{skimr} package is installed, an in-line histogram is 101 | #' added for all numeric variables. If columns are labelled, the labelles 102 | #' are included in the codebook. 103 | #' @return Returns `NULL` invisibly. 104 | #' @seealso [utils::write.csv()] 105 | #' @export 106 | #' 107 | #' @examples 108 | #' variable_labels(cars) <- c(speed = "Speed [ft/s]", dist = "Distance traveled [m]") 109 | #' simple_codebook(cars, file = file.path(tempdir(), "cars_codebook.csv")) 110 | 111 | simple_codebook <- function(x, ...) { 112 | tidied_labels <- tidy_variable_lables(x) 113 | utils::write.csv(tidied_labels, ...) 114 | } 115 | -------------------------------------------------------------------------------- /README_files/figure-gfm/dep-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/figure-gfm/dep-plot-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/stroop-ggplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/figure-gfm/stroop-ggplot-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/stroop-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/figure-gfm/stroop-plot-1.png -------------------------------------------------------------------------------- /README_files/figure-html/dep-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/figure-html/dep-plot-1.png -------------------------------------------------------------------------------- /README_files/figure-html/stroop-ggplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/figure-html/stroop-ggplot-1.png -------------------------------------------------------------------------------- /README_files/figure-html/stroop-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/figure-html/stroop-plot-1.png -------------------------------------------------------------------------------- /README_files/libs/bootstrap/bootstrap-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/README_files/libs/bootstrap/bootstrap-icons.woff -------------------------------------------------------------------------------- /README_files/libs/quarto-html/tippy.css: -------------------------------------------------------------------------------- 1 | .tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1} -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | 3 | - macOS 12.1, R 4.3.1 (local) 4 | - macOS-latest, R-release (r-lib actions) 5 | - Apple Silicon (M1), macOS 11.6 Big Sur, R-release (r-hub) 6 | - Windows Server 2022, R-devel (win-builder) 7 | - Windows Server 2008, R-release (win-builder) 8 | - Windows-latest, R-release (r-lib actions) 9 | - Ubuntu 20.04, R-devel (r-lib actions) 10 | - Ubuntu 20.04, R-release (r-lib actions) 11 | - Ubuntu 20.04, R-oldrel (r-lib actions) 12 | - Fedora Linux, R-devel, clang, gfortran (r-hub) 13 | 14 | ## R CMD check results 15 | 16 | 0 ERRORs | 0 WARNINGs | 1 NOTE 17 | 18 | * checking CRAN incoming feasibility ... NOTE 19 | Maintainer: 'Frederik Aust ' 20 | 21 | New submission 22 | 23 | Package was archived on CRAN 24 | 25 | CRAN repository db overrides: 26 | X-CRAN-Comment: Archived on 2023-09-26 as check issues were not corrected in time. 27 | 28 | Found the following (possibly) invalid URLs: 29 | URL: https://stackoverflow.com/help/minimal-reproducible-example 30 | From: man/papaja.Rd 31 | README.md 32 | Status: 404 33 | Message: Not Found 34 | 35 | 36 | ## Comments 37 | 38 | This is a resubmission, to address the invalid use of 'paired' in formula method of t.test() and wilcoxon.test() (https://cran-archive.r-project.org/web/checks/2023/2023-09-26_check_results_papaja.html) 39 | 40 | All URLs are correct. Maybe the sites are blocking non-human traffic? 41 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | 2 | year <- sub("-.*", "", meta$Date) 3 | note <- paste0("R package version ", meta$Version) 4 | 5 | 6 | bibentry( 7 | bibtype = "Manual" 8 | , textVersion = paste0( 9 | "Aust, F. & Barth, M. (" 10 | , year 11 | , "). papaja: Prepare reproducible APA journal articles with R Markdown. " 12 | , note 13 | , ". Retrieved from " 14 | , meta$URL 15 | ) 16 | , title = "{papaja}: {Prepare} reproducible {APA} journal articles with {R Markdown}" 17 | , author = c( 18 | person("Frederik", "Aust") 19 | , person("Marius", "Barth") 20 | ) 21 | , year = year 22 | , note = note 23 | , url = meta$URL 24 | , doi = "10.32614/CRAN.package.papaja" 25 | ) 26 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | APA 2 | APAstats 3 | Algina 4 | Anova 5 | BFBayesFactor 6 | BFBayesFactorList 7 | BFBayesFactorTop 8 | BCP 9 | Bakeman 10 | CMD 11 | CSL 12 | CodeOcean 13 | Codebook 14 | Colour 15 | Cousineau 16 | DOCX 17 | FFF 18 | Feldt 19 | Geisser 20 | HDI 21 | HDIs 22 | Huyn 23 | Kernighan 24 | Keselman 25 | Loftus 26 | METACRAN 27 | MacTeX 28 | Masson's 29 | MikTeX 30 | Morey 31 | ORCID 32 | Pandoc's 33 | Penfield 34 | RMarkdown 35 | RStudio 36 | RStudio's 37 | Ritchie 38 | Scheffé 39 | Schrön 40 | StackOverflow 41 | Steiger 42 | Stroop 43 | TinyTex 44 | WIP 45 | Wagenmakers 46 | YAML 47 | Zotero 48 | addin 49 | afex 50 | al 51 | anova 52 | aov 53 | aovlist 54 | apa 55 | apaTables 56 | asis 57 | assertthat 58 | aust 59 | barth 60 | beeswarm 61 | bookdown 62 | citable 63 | citeproc 64 | citr 65 | codebook 66 | codecov 67 | crsh 68 | de 69 | df 70 | docx 71 | doi 72 | dplyr 73 | emm 74 | emmGrid 75 | et 76 | evidential 77 | frac 78 | frederik 79 | github 80 | glht 81 | glm 82 | htest 83 | https 84 | jss 85 | koeln 86 | labelled 87 | labelles 88 | labelling 89 | leftskip 90 | lm 91 | lme 92 | localizations 93 | logoColor 94 | lsmobj 95 | manova 96 | marius 97 | merMod 98 | midrules 99 | mlm 100 | nonnormal 101 | nonnormality 102 | nrow 103 | pandoc 104 | parindent 105 | participants’ 106 | priori 107 | rempsy 108 | reportable 109 | reproducibility 110 | rowwise 111 | rstudio 112 | rticles 113 | semipartial 114 | setlength 115 | significances 116 | sigr 117 | sphericity 118 | spl 119 | tex 120 | tinylabels 121 | th 122 | wsci 123 | xtable 124 | yaml 125 | yml 126 | rempsyc 127 | -------------------------------------------------------------------------------- /inst/example/example.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/example/example.docx -------------------------------------------------------------------------------- /inst/example/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/example/example.pdf -------------------------------------------------------------------------------- /inst/example/example_files/figure-latex/beeplot-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/example/example_files/figure-latex/beeplot-1.pdf -------------------------------------------------------------------------------- /inst/example/example_files/figure-latex/beeplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/example/example_files/figure-latex/beeplot-1.png -------------------------------------------------------------------------------- /inst/example/references.bib: -------------------------------------------------------------------------------- 1 | @book {james_1890, 2 | Title = {The principles of psychology}, 3 | Author = {James, William}, 4 | Year = {1890}, 5 | address = {Holt: New York} 6 | } 7 | 8 | @article {bem_2011, 9 | Title = {Feeling the future: experimental evidence for anomalous retroactive influences on cognition and affect}, 10 | Author = {Bem, Daryl J}, 11 | DOI = {10.1037/a0021524}, 12 | Number = {3}, 13 | Volume = {100}, 14 | Month = {March}, 15 | Year = {2011}, 16 | Journal = {Journal of personality and social psychology}, 17 | ISSN = {0022-3514}, 18 | Pages = {407—425}, 19 | URL = {https://doi.org/10.1037/a0021524}, 20 | } 21 | -------------------------------------------------------------------------------- /inst/images/knitting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/images/knitting.png -------------------------------------------------------------------------------- /inst/images/template_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/images/template_selection.png -------------------------------------------------------------------------------- /inst/lua/abstract_to_meta.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | https://github.com/pandoc/lua-filters/blob/master/abstract-to-meta/abstract-to-meta.lua 3 | 4 | Turns section with ID "abstract" into metadata element 5 | ]] 6 | 7 | local looking_at_abstract = false 8 | local abstract = {} 9 | 10 | local looking_at_authornote = false 11 | local authornote = {} 12 | 13 | function Block (elem) 14 | if looking_at_abstract then 15 | abstract[#abstract + 1] = elem 16 | return {} 17 | end 18 | if looking_at_authornote then 19 | authornote[#authornote + 1] = elem 20 | return {} 21 | end 22 | end 23 | 24 | function HorizontalRule (elem) 25 | if looking_at_abstract then 26 | looking_at_abstract = false 27 | return {} 28 | end 29 | if looking_at_authornote then 30 | looking_at_authornote = false 31 | return {} 32 | end 33 | end 34 | 35 | function Header (elem) 36 | if elem.level == 1 and elem.identifier == 'abstract' then 37 | looking_at_abstract = true 38 | return {} 39 | else 40 | looking_at_abstract = looking_at_abstract and elem.level ~= 1 41 | end 42 | if elem.level == 1 and elem.identifier == 'authornote' then 43 | looking_at_authornote = true 44 | return {} 45 | else 46 | looking_at_authornote = looking_at_authornote and elem.level ~= 1 47 | end 48 | if elem.level == 1 and elem.identifier == 'title' then 49 | return {} 50 | end 51 | end 52 | 53 | function Meta (meta) 54 | meta.abstract = meta.abstract or pandoc.MetaBlocks(abstract) 55 | meta.authornote = meta.authornote or pandoc.MetaBlocks(authornote) 56 | return meta 57 | end 58 | -------------------------------------------------------------------------------- /inst/lua/docx_fixes.lua: -------------------------------------------------------------------------------- 1 | if FORMAT ~= "docx" then 2 | return 3 | end 4 | 5 | function Header (elem) 6 | if elem.level >= 3 then 7 | elem.content[#elem.content + 1] = pandoc.Str(".") 8 | end 9 | 10 | return elem 11 | end 12 | 13 | function Figure (fig) 14 | if fig.caption and #fig.caption.long > 0 then 15 | 16 | local caption = fig.caption.long[1].content 17 | 18 | if #caption >= 4 then 19 | caption[2] = pandoc.Emph(caption[2]) 20 | -- Remove the colon from the 4th element (if it's a string) 21 | if caption[4] and pandoc.utils.stringify(caption[4]):match(":") then 22 | caption[4] = pandoc.Str(string.gsub(pandoc.utils.stringify(caption[4]), ":", ".")) 23 | end 24 | end 25 | 26 | -- Assign the modified caption back to the table 27 | fig.caption.long[1].content = caption 28 | end 29 | 30 | -- Return the modified table 31 | return fig 32 | end 33 | 34 | function Table (tbl) 35 | -- Check if tbl.caption.long is not empty 36 | if tbl.caption and #tbl.caption.long > 0 then 37 | 38 | local caption = tbl.caption.long[1].content 39 | 40 | -- Modify the caption only if there are enough elements 41 | if #caption >= 4 then 42 | -- Remove the colon from the 4th element (if it's a string) 43 | if caption[4] and pandoc.utils.stringify(caption[4]):match(":") then 44 | caption[4] = pandoc.Str(string.gsub(pandoc.utils.stringify(caption[4]), ":", "")) 45 | end 46 | 47 | -- Add a line break as the 5th element 48 | if #caption >= 5 then 49 | caption[5] = pandoc.LineBreak() 50 | else 51 | table.insert(caption, 5, pandoc.LineBreak()) 52 | end 53 | 54 | for i = 6, (#caption) do 55 | caption[i] = pandoc.Emph(caption[i]) 56 | end 57 | end 58 | 59 | -- Assign the modified caption back to the table 60 | tbl.caption.long[1].content = caption 61 | end 62 | 63 | -- Return the modified table 64 | return tbl 65 | end 66 | -------------------------------------------------------------------------------- /inst/lua/label_quotes.lua: -------------------------------------------------------------------------------- 1 | function Str(elem) 2 | i, j = string.match(elem.text, "^<@~") 3 | k, l = string.match(elem.text, "^~@>") 4 | 5 | if i ~= nil or k ~= nil then 6 | if FORMAT:match "latex" then 7 | return pandoc.RawInline("latex", "% " .. elem.text) 8 | else 9 | return pandoc.Str("") 10 | end 11 | else 12 | return elem 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /inst/lua/reviewer_comment.lua: -------------------------------------------------------------------------------- 1 | function Div(el) 2 | if el.classes[1] == "reviewer" then 3 | -- insert element in front 4 | table.insert( 5 | el.content, 1, 6 | pandoc.RawBlock("latex", "\\begin{reviewer}")) 7 | -- insert element at the back 8 | table.insert( 9 | el.content, 10 | pandoc.RawBlock("latex", "\\end{reviewer}")) 11 | end 12 | return el 13 | end 14 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/apa6/resources/apa6_header_includes.tex: -------------------------------------------------------------------------------- 1 | % Manuscript styling 2 | \usepackage{upgreek} 3 | \captionsetup{font=singlespacing,justification=justified} 4 | 5 | % Table formatting 6 | \usepackage{longtable} 7 | \usepackage{lscape} 8 | % \usepackage[counterclockwise]{rotating} % Landscape page setup for large tables 9 | \usepackage{multirow} % Table styling 10 | \usepackage{tabularx} % Control Column width 11 | \usepackage[flushleft]{threeparttable} % Allows for three part tables with a specified notes section 12 | \usepackage{threeparttablex} % Lets threeparttable work with longtable 13 | 14 | % Create new environments so endfloat can handle them 15 | % \newenvironment{ltable} 16 | % {\begin{landscape}\centering\begin{threeparttable}} 17 | % {\end{threeparttable}\end{landscape}} 18 | \newenvironment{lltable}{\begin{landscape}\centering\begin{ThreePartTable}}{\end{ThreePartTable}\end{landscape}} 19 | 20 | % Enables adjusting longtable caption width to table width 21 | % Solution found at http://golatex.de/longtable-mit-caption-so-breit-wie-die-tabelle-t15767.html 22 | \makeatletter 23 | \newcommand\LastLTentrywidth{1em} 24 | \newlength\longtablewidth 25 | \setlength{\longtablewidth}{1in} 26 | \newcommand{\getlongtablewidth}{\begingroup \ifcsname LT@\roman{LT@tables}\endcsname \global\longtablewidth=0pt \renewcommand{\LT@entry}[2]{\global\advance\longtablewidth by ##2\relax\gdef\LastLTentrywidth{##2}}\@nameuse{LT@\roman{LT@tables}} \fi \endgroup} 27 | 28 | % \setlength{\parindent}{0.5in} 29 | % \setlength{\parskip}{0pt plus 0pt minus 0pt} 30 | 31 | % Overwrite redefinition of paragraph and subparagraph by the default LaTeX template 32 | % See https://github.com/crsh/papaja/issues/292 33 | \makeatletter 34 | \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}% 35 | {0\baselineskip \@plus 0.2ex \@minus 0.2ex}% 36 | {-1em}% 37 | {\normalfont\normalsize\bfseries\itshape\typesectitle}} 38 | 39 | \renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}% 40 | {0\baselineskip \@plus 0.2ex \@minus 0.2ex}% 41 | {-\z@\relax}% 42 | {\normalfont\normalsize\itshape\hspace{\parindent}{#1}\textit{\addperi}}{\relax}} 43 | \makeatother 44 | 45 | \makeatletter 46 | \usepackage{etoolbox} 47 | \patchcmd{\maketitle} 48 | {\section{\normalfont\normalsize\abstractname}} 49 | {\section*{\normalfont\normalsize\abstractname}} 50 | {}{\typeout{Failed to patch abstract.}} 51 | \patchcmd{\maketitle} 52 | {\section{\protect\normalfont{\@title}}} 53 | {\section*{\protect\normalfont{\@title}}} 54 | {}{\typeout{Failed to patch title.}} 55 | \makeatother 56 | 57 | \usepackage{xpatch} 58 | \makeatletter 59 | \xapptocmd\appendix 60 | {\xapptocmd\section 61 | {\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi: #1}} 62 | {}{\InnerPatchFailed}% 63 | } 64 | {}{\PatchFailed} 65 | \makeatother 66 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/apa6/resources/apa6_man.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/rmarkdown/templates/apa6/resources/apa6_man.docx -------------------------------------------------------------------------------- /inst/rmarkdown/templates/apa6/resources/apa6_man_.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/inst/rmarkdown/templates/apa6/resources/apa6_man_.docx -------------------------------------------------------------------------------- /inst/rmarkdown/templates/apa6/skeleton/skeleton.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title : "The title" 3 | shorttitle : "Title" 4 | 5 | author: 6 | - name : "First Author" 7 | affiliation : "1" 8 | corresponding : yes # Define only one corresponding author 9 | address : "Postal address" 10 | email : "my@email.com" 11 | role: # Contributorship roles (e.g., CRediT, https://credit.niso.org/) 12 | - "Conceptualization" 13 | - "Writing - Original Draft Preparation" 14 | - "Writing - Review & Editing" 15 | - name : "Ernst-August Doelle" 16 | affiliation : "1,2" 17 | role: 18 | - "Writing - Review & Editing" 19 | - "Supervision" 20 | 21 | affiliation: 22 | - id : "1" 23 | institution : "Wilhelm-Wundt-University" 24 | - id : "2" 25 | institution : "Konstanz Business School" 26 | 27 | authornote: | 28 | Add complete departmental affiliations for each author here. Each new line herein must be indented, like this line. 29 | 30 | Enter author note here. 31 | 32 | abstract: | 33 | One or two sentences providing a **basic introduction** to the field, comprehensible to a scientist in any discipline. 34 | Two to three sentences of **more detailed background**, comprehensible to scientists in related disciplines. 35 | One sentence clearly stating the **general problem** being addressed by this particular study. 36 | One sentence summarizing the main result (with the words "**here we show**" or their equivalent). 37 | 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. 38 | One or two sentences to put the results into a more **general context**. 39 | Two or three sentences to provide a **broader perspective**, readily comprehensible to a scientist in any discipline. 40 | 41 | 42 | 43 | keywords : "keywords" 44 | wordcount : "X" 45 | 46 | bibliography : "r-references.bib" 47 | 48 | floatsintext : no 49 | linenumbers : yes 50 | draft : no 51 | mask : no 52 | 53 | figurelist : no 54 | tablelist : no 55 | footnotelist : no 56 | 57 | classoption : "man" 58 | output : papaja::apa6_pdf 59 | --- 60 | 61 | ```{r setup, include = FALSE} 62 | library("papaja") 63 | r_refs("r-references.bib") 64 | ``` 65 | 66 | ```{r analysis-preferences} 67 | # Seed for random number generation 68 | set.seed(42) 69 | knitr::opts_chunk$set(cache.extra = knitr::rand_seed) 70 | ``` 71 | 72 | 73 | 74 | # Methods 75 | We report how we determined our sample size, all data exclusions (if any), all manipulations, and all measures in the study. 76 | 77 | ## Participants 78 | 79 | ## Material 80 | 81 | ## Procedure 82 | 83 | ## Data analysis 84 | We used `r cite_r("r-references.bib")` for all our analyses. 85 | 86 | 87 | # Results 88 | 89 | # Discussion 90 | 91 | 92 | \newpage 93 | 94 | # References 95 | 96 | ::: {#refs custom-style="Bibliography"} 97 | ::: 98 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/apa6/template.yaml: -------------------------------------------------------------------------------- 1 | name: APA-style manuscript (6th edition) 2 | description: > 3 | Create manuscripts in accordance with APA manuscript guidelines (6th edition; PDF or MS Word). 4 | create_dir: false 5 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/revision_letter/skeleton/skeleton.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title : "Manuscript title" 3 | authors : "First Author & Second Author" 4 | journal : "Journal title" 5 | manuscript-id : "Manuscript number" 6 | manuscript-src : "headings" 7 | 8 | cutout-quotes : true 9 | class : "draft" 10 | output : papaja::revision_letter_pdf 11 | --- 12 | 13 | Dear Dr. Editor, 14 | 15 | thank you very much for taking the time to consider our manuscript for publication at _`r rmarkdown::metadata$journal`_. 16 | In the following we address your and each reviewers' concerns point-by-point. 17 | 18 | 19 | # Reviewer \#1 20 | 21 | :::reviewer 22 | This is a reviewer comment 23 | ::: 24 | 25 | This is our response 26 | 27 | \Assignment{First Author} 28 | \WorkInProgress 29 | \Easy 30 | 31 | 32 | :::reviewer 33 | \label{pt:foo} 34 | This is a reviewer comment 35 | 36 | Still a comment 37 | ::: 38 | 39 | This is our response. 40 | 41 | > This is a section quoted from the revised manuscript to illustrate the change. 42 | 43 | \Assignment{Second Author} 44 | \AlmostDone 45 | \Medium 46 | 47 | 48 | :::reviewer 49 | This is a reviewer comment 50 | ::: 51 | 52 | This is our response. Also see RC \@ref(pt:foo) 53 | 54 | \Assignment{First Author} 55 | \Done 56 | \TimeConsuming 57 | \Hard 58 | \NotEstimated 59 | 60 | 61 | # Reviewer 2 62 | 63 | :::reviewer 64 | This is a reviewer comment 65 | ::: 66 | 67 | This is our response 68 | 69 | 70 | # References {-} 71 | 72 | ::: {#refs custom-style="Bibliography"} 73 | ::: 74 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/revision_letter/template.yaml: -------------------------------------------------------------------------------- 1 | name: Revision letter (PDF) 2 | description: > 3 | Create journal revision letters in PDF format. 4 | create_dir: false 5 | -------------------------------------------------------------------------------- /man/add_col_spanners.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_table.R 3 | \name{add_col_spanners} 4 | \alias{add_col_spanners} 5 | \title{Add table headings to group columns} 6 | \usage{ 7 | add_col_spanners(table_lines, col_spanners, n_cols, add_group_midrules = TRUE) 8 | } 9 | \arguments{ 10 | \item{table_lines}{Character. Vector of characters containing one line of a LaTeX table each.} 11 | 12 | \item{col_spanners}{List. A named list containing the indices of the first and last columns to group, where the names are the headings.} 13 | 14 | \item{n_cols}{Numeric. Number of columns of the table.} 15 | 16 | \item{add_group_midrules}{Logical.Determines whether group midrules are added.} 17 | } 18 | \description{ 19 | Takes a named list of containing column numbers to group with a heading 20 | \emph{This function is not exported.} 21 | } 22 | \seealso{ 23 | \code{\link[=apa_table]{apa_table()}} 24 | } 25 | \keyword{internal} 26 | -------------------------------------------------------------------------------- /man/add_effect_sizes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calculations.R 3 | \name{add_effect_sizes} 4 | \alias{add_effect_sizes} 5 | \title{Effect Sizes for Analysis of Variance} 6 | \usage{ 7 | add_effect_sizes(x, es = "ges", observed = NULL, intercept = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{apa_variance_table}.} 11 | 12 | \item{es}{Character. A vector naming all to-be-computed effect-size measures. 13 | Currently, partial eta-squared (\code{"pes"}), generalized eta-squared 14 | (\code{"ges"}), and eta-squared (\code{"es"}) are supported.} 15 | 16 | \item{observed}{Character. A vector naming all factors that are observed 17 | (i.e., \emph{not} manipulated).} 18 | 19 | \item{intercept}{Logical. Should the sum of squares of the intercept (i.e., the 20 | deviation of the grand mean from 0) be included in the calculation of eta-squared?} 21 | } 22 | \description{ 23 | Calculates effect-size measures for Analysis of Variance output objects. 24 | \emph{This function is not exported and will soon be deprecated.} 25 | } 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /man/add_equals.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_text.R 3 | \name{add_equals} 4 | \alias{add_equals} 5 | \title{Add Equals Where Necessary} 6 | \usage{ 7 | add_equals(x) 8 | } 9 | \arguments{ 10 | \item{x}{A character vector.} 11 | } 12 | \value{ 13 | Character vector 14 | } 15 | \description{ 16 | This is an internal function that prepends every element of a character 17 | vector with an 'equals' sign if the respective element does not contain one 18 | of \code{c("=", "<", ">")}. 19 | } 20 | \examples{ 21 | add_equals(c("42", "<= 42", "> 42", "= 42")) 22 | } 23 | -------------------------------------------------------------------------------- /man/add_row_names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_table.R 3 | \name{add_row_names} 4 | \alias{add_row_names} 5 | \title{Add row names as first column} 6 | \usage{ 7 | add_row_names(x, added_stub_head, force = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{data.frame or matrix.} 11 | 12 | \item{added_stub_head}{Character. Used as stub head (name of first column).} 13 | 14 | \item{force}{Logical. Should row names be added even if they are the numbers 1:nrow(x)?} 15 | } 16 | \description{ 17 | Adds row names as the first column of the table and sets \code{row.name} attribute to \code{NULL}. 18 | \emph{This function is not exported.} 19 | } 20 | \seealso{ 21 | \code{\link[=apa_table]{apa_table()}} 22 | } 23 | \keyword{internal} 24 | -------------------------------------------------------------------------------- /man/apa6_pdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa6_formats.R 3 | \name{apa6_pdf} 4 | \alias{apa6_pdf} 5 | \alias{apa6_docx} 6 | \alias{apa6_word} 7 | \alias{apa6_doc} 8 | \title{APA manuscript (6th edition)} 9 | \usage{ 10 | apa6_pdf( 11 | fig_caption = TRUE, 12 | number_sections = FALSE, 13 | toc = FALSE, 14 | keep_tex = TRUE, 15 | md_extensions = NULL, 16 | includes = NULL, 17 | ... 18 | ) 19 | 20 | apa6_docx( 21 | fig_caption = TRUE, 22 | number_sections = FALSE, 23 | md_extensions = NULL, 24 | ... 25 | ) 26 | 27 | apa6_word(...) 28 | 29 | apa6_doc(...) 30 | } 31 | \arguments{ 32 | \item{fig_caption}{\code{TRUE} to render figures with captions} 33 | 34 | \item{number_sections}{\code{TRUE} to number section headings} 35 | 36 | \item{toc}{\code{TRUE} to include a table of contents in the output} 37 | 38 | \item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF. 39 | Note that this argument does not control whether to keep the auxiliary 40 | files (e.g., \file{.aux}) generated by LaTeX when compiling \file{.tex} to 41 | \file{.pdf}. To keep these files, you may set \code{options(tinytex.clean = 42 | FALSE)}.} 43 | 44 | \item{md_extensions}{Markdown extensions to be added or removed from the 45 | default definition of R Markdown. See the 46 | \code{\link[rmarkdown]{rmarkdown_format}} for additional details.} 47 | 48 | \item{includes}{Named list of additional content to include within the 49 | document (typically created using the \code{\link[rmarkdown]{includes}} function).} 50 | 51 | \item{...}{Further arguments to pass to 52 | \code{\link[bookdown]{pdf_document2}} or 53 | \code{\link[bookdown]{word_document2}}.} 54 | } 55 | \value{ 56 | R Markdown output format to pass to \code{\link[rmarkdown:render]{rmarkdown::render()}}. 57 | } 58 | \description{ 59 | Template for creating an article according to APA guidelines (6th edition) 60 | in PDF or DOCX format. 61 | } 62 | \details{ 63 | When creating PDF documents the YAML option \code{classoption} is passed 64 | to the class options of the LaTeX apa6 document class. In this case, 65 | additional options are available. Refer to the \code{apa6} document class 66 | \href{ftp://ftp.fu-berlin.de/tex/CTAN/macros/latex/contrib/apa6/apa6.pdf}{documentation} 67 | to find out about class options such as paper size or draft watermarks. 68 | 69 | Please refer to the \href{https://frederikaust.com/papaja_man/r-markdown-components.html#yaml-front-matter}{\pkg{papaja} online-manual} 70 | for additional information on available YAML front matter settings. 71 | Note that the available settings for DOCX documents are more limited 72 | than for PDF documents. 73 | 74 | When creating PDF documents the output device for figures defaults to 75 | \code{c("pdf", "png")}, so that each figure is saved in all four formats 76 | at a resolution of 300 dpi. 77 | } 78 | \section{Functions}{ 79 | \itemize{ 80 | \item \code{apa6_word()}: Format to create .docx-files. Alias of \code{apa6_docx}. 81 | 82 | \item \code{apa6_doc()}: Format to create .docx-files. Alias of \code{apa6_docx}. 83 | 84 | }} 85 | \seealso{ 86 | \code{\link[bookdown:html_document2]{bookdown::pdf_document2()}}, \code{\link[bookdown:html_document2]{bookdown::word_document2()}} 87 | } 88 | -------------------------------------------------------------------------------- /man/apa_df.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_num.R 3 | \name{apa_df} 4 | \alias{apa_df} 5 | \alias{print_df} 6 | \title{Typeset Degrees of Freedom} 7 | \usage{ 8 | apa_df(x, digits = 2L, big.mark = "", elementwise = TRUE) 9 | 10 | print_df(x, digits = 2L, big.mark = "", elementwise = TRUE) 11 | } 12 | \arguments{ 13 | \item{x}{Numeric. The degrees of freedom to report.} 14 | 15 | \item{digits}{Integer. The desired number of digits after the decimal point to 16 | be used if \code{x} contains non-integer values.} 17 | 18 | \item{big.mark}{character; if not empty used as mark between every 19 | \code{big.interval} decimals \emph{before} (hence \code{big}) the 20 | decimal point.} 21 | 22 | \item{elementwise}{Logical. Determines whether the number of trailing digits 23 | should be determined for each element of \code{x} separately (the default), 24 | or for the complete vector \code{x}.} 25 | } 26 | \value{ 27 | An object of the same class as \code{x} with all numeric values converted 28 | to character. 29 | } 30 | \description{ 31 | This is a function for processing degrees of freedom. It takes care 32 | that trailing digits are only printed if non-integer values are given. 33 | } 34 | \examples{ 35 | apa_df(c(1, 1.23151)) 36 | } 37 | \seealso{ 38 | \code{\link[=apa_num]{apa_num()}}, \code{\link[=apa_p]{apa_p()}} 39 | } 40 | -------------------------------------------------------------------------------- /man/apa_factorial_plot_single.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_factorial_plot.R 3 | \name{apa_factorial_plot_single} 4 | \alias{apa_factorial_plot_single} 5 | \title{Plots for factorial designs that conform to APA guidelines, two-factors internal function} 6 | \usage{ 7 | apa_factorial_plot_single( 8 | aggregated, 9 | y.values, 10 | id, 11 | dv, 12 | factors, 13 | intercept = NULL, 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{aggregated}{A \code{data.frame}, the \emph{aggregated} data.} 19 | 20 | \item{y.values}{A \code{data.frame} containing the measures of central tendency and of dispersion per cell of the design.} 21 | 22 | \item{id}{Character. Variable name that identifies subjects.} 23 | 24 | \item{dv}{Character. The name of the dependent variable.} 25 | 26 | \item{factors}{Character. A vector of up to four variable names that is used to stratify the data.} 27 | 28 | \item{intercept}{Numeric. See details in \code{\link[=apa_factorial_plot]{apa_factorial_plot()}}} 29 | } 30 | \description{ 31 | Internal function that is called (possibly multiple times) by \code{\link[=apa_factorial_plot]{apa_factorial_plot()}}. 32 | } 33 | \keyword{internal} 34 | -------------------------------------------------------------------------------- /man/apa_interval.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_interval.R 3 | \name{apa_interval} 4 | \alias{apa_interval} 5 | \alias{print_interval} 6 | \alias{apa_interval.numeric} 7 | \alias{apa_interval.matrix} 8 | \alias{apa_interval.data.frame} 9 | \alias{apa_interval.list} 10 | \alias{apa_confint} 11 | \alias{print_confint} 12 | \alias{apa_hdint} 13 | \alias{print_hdint} 14 | \title{Typeset Interval Estimate} 15 | \usage{ 16 | apa_interval(x, ...) 17 | 18 | print_interval(x, ...) 19 | 20 | \method{apa_interval}{numeric}( 21 | x, 22 | y = NULL, 23 | ..., 24 | conf.int = NULL, 25 | interval_type = NULL, 26 | enclose_math = FALSE 27 | ) 28 | 29 | \method{apa_interval}{matrix}( 30 | x, 31 | ..., 32 | conf.int = NULL, 33 | interval_type = NULL, 34 | enclose_math = FALSE 35 | ) 36 | 37 | \method{apa_interval}{data.frame}( 38 | x, 39 | ..., 40 | conf.int = NULL, 41 | interval_type = NULL, 42 | enclose_math = FALSE 43 | ) 44 | 45 | \method{apa_interval}{list}( 46 | x, 47 | ..., 48 | conf.int = NULL, 49 | interval_type = NULL, 50 | enclose_math = FALSE 51 | ) 52 | 53 | apa_confint( 54 | x, 55 | ..., 56 | conf.int = NULL, 57 | interval_type = "CI", 58 | enclose_math = FALSE 59 | ) 60 | 61 | print_confint( 62 | x, 63 | ..., 64 | conf.int = NULL, 65 | interval_type = "CI", 66 | enclose_math = FALSE 67 | ) 68 | 69 | apa_hdint(x, ..., conf.int = NULL, interval_type = "HDI", enclose_math = FALSE) 70 | 71 | print_hdint( 72 | x, 73 | ..., 74 | conf.int = NULL, 75 | interval_type = "HDI", 76 | enclose_math = FALSE 77 | ) 78 | } 79 | \arguments{ 80 | \item{x}{Numeric. A vector (of length 2, unless \code{y} is also specified) with, 81 | a two-column \code{matrix}, or a \code{data.frame}, which can coerced to a \code{matrix}.} 82 | 83 | \item{...}{Further arguments passed on to \code{\link[=apa_num]{apa_num()}}.} 84 | 85 | \item{y}{Numeric. An optional vector of the same length as \code{x}.} 86 | 87 | \item{conf.int}{Numeric. Confidence level of the interval. Ignored if 88 | level can be inferred from attributes of \code{x}, see Details.} 89 | 90 | \item{interval_type}{Character. Abbreviation indicating the type of interval 91 | estimate, e.g. \code{CI}.} 92 | 93 | \item{enclose_math}{Logical. Indicates whether the interval should be 94 | enclosed in \code{$} (i.e., a math environment).} 95 | } 96 | \value{ 97 | A single interval is returned as a \code{character} vector of length 1; 98 | multiple intervals are returned as a named \code{list} of \code{character} vectors 99 | of length 1. 100 | } 101 | \description{ 102 | Creates a character string to report interval estimates, such as frequentist 103 | confidence or Bayesian credible intervals. 104 | } 105 | \details{ 106 | If possible the confidence level of the interval is inferred from 107 | attributes of \code{x}. For a vector of length 2, the attribute \code{conf.level} is 108 | is consulted; for a \code{matrix} or \code{data.frame} the column names are used, 109 | if they are of the format "2.5 \\%" and "97.5 \\%". 110 | 111 | If \code{x} is a \code{matrix} or \code{data.frame} the row names are used as names for 112 | the returned \code{list} of intervals. 113 | } 114 | \examples{ 115 | apa_confint(1, 2, conf.int = 0.95) 116 | apa_confint(c(1, 2), conf.int = 0.95) 117 | apa_confint(matrix(c(1, 2), ncol = 2), conf.int = 0.95) 118 | apa_confint(confint(lm(cars))) 119 | apa_confint(confint(lm(cars)), digits = 3) 120 | } 121 | \seealso{ 122 | \code{\link[=apa_num]{apa_num()}} 123 | } 124 | -------------------------------------------------------------------------------- /man/apa_p.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_num.R 3 | \name{apa_p} 4 | \alias{apa_p} 5 | \alias{printp} 6 | \alias{print_p} 7 | \title{Prepare Numeric Values for Printing as p value} 8 | \usage{ 9 | apa_p(x, digits = 3L, na_string = "", add_equals = FALSE) 10 | 11 | printp(x, digits = 3L, na_string = "", add_equals = FALSE) 12 | 13 | print_p(x, digits = 3L, na_string = "", add_equals = FALSE) 14 | } 15 | \arguments{ 16 | \item{x}{Numeric. The \emph{p} value(s) to report.} 17 | 18 | \item{digits}{Integer. The desired number of digits after the decimal point, passed on to \code{\link{formatC}}.} 19 | 20 | \item{na_string}{Character. String to print if any element of \code{x} is \code{NA}.} 21 | 22 | \item{add_equals}{Logical. Indicates if the output string should be 23 | prepended with an \code{=}.} 24 | } 25 | \value{ 26 | An object of the same class as \code{x} with all numeric values converted 27 | to character. 28 | } 29 | \description{ 30 | Convenience wrapper for \code{\link{apa_num}} to print \emph{p} values. 31 | } 32 | \examples{ 33 | apa_p(0.05) 34 | apa_p(0.0005) 35 | apa_p(0.99999999) 36 | apa_p(c(.001, 0), add_equals = TRUE) 37 | } 38 | \seealso{ 39 | \code{\link[=apa_num]{apa_num()}}, \code{\link[=apa_df]{apa_df()}} 40 | } 41 | -------------------------------------------------------------------------------- /man/apa_prepare_doc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_defunct.R 3 | \name{apa_prepare_doc} 4 | \alias{apa_prepare_doc} 5 | \title{Prepare APA document (deprecated)} 6 | \usage{ 7 | apa_prepare_doc() 8 | } 9 | \value{ 10 | Returns \code{NULL} invisibly. 11 | } 12 | \description{ 13 | Prepares objects to be used in the rendering process and creates title page 14 | and abstract for MS Word documents. \emph{This function has been defunct. It is 15 | no longer needed.} 16 | } 17 | \details{ 18 | The function creates and locks a non-exported object \code{apa_lang} 19 | that is used by other \pkg{papaja}-functions. \code{apa_lang} is a 20 | \code{list} containing localizations for document elements such as abstract 21 | and title. The selected language is defined by the \code{lang}-parameter 22 | in the documents yaml-header. Currently, English (default) and German 23 | (\code{"german"}) are supported. 24 | 25 | If the output document is MS Word (\verb{output: \link{apa6_word}}) the 26 | function additionally creates a title page and adds the abstract. You 27 | should, therefore, always call \code{apa_prepare_doc} at the very 28 | beginning of the R Markdown document. 29 | } 30 | \seealso{ 31 | \code{\link[=apa6_docx]{apa6_docx()}} 32 | } 33 | -------------------------------------------------------------------------------- /man/apa_print.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_print.R 3 | \name{apa_print} 4 | \alias{apa_print} 5 | \title{Typeset Statistical Results} 6 | \usage{ 7 | apa_print(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A model object.} 11 | 12 | \item{...}{Additional arguments passed to methods.} 13 | } 14 | \description{ 15 | A generic function that takes objects from various statistical methods to 16 | create formatted character strings to report the results in accordance with 17 | APA manuscript guidelines. The function invokes particular methods, which 18 | depend on the \code{\link{class}} of the first argument. 19 | } 20 | \examples{ 21 | # List methods for apa_print() 22 | methods("apa_print") 23 | } 24 | \seealso{ 25 | Other apa_print: 26 | \code{\link{apa_print.BFBayesFactor}()}, 27 | \code{\link{apa_print.aov}()}, 28 | \code{\link{apa_print.emmGrid}()}, 29 | \code{\link{apa_print.glht}()}, 30 | \code{\link{apa_print.htest}()}, 31 | \code{\link{apa_print.list}()}, 32 | \code{\link{apa_print.lm}()}, 33 | \code{\link{apa_print.lme}()}, 34 | \code{\link{apa_print.merMod}()} 35 | } 36 | \concept{apa_print} 37 | \value{ 38 | \code{apa_print()}-methods return a named list of class \code{apa_results} containing the following elements: 39 | 40 | \item{estimate}{One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 41 | \item{statistic}{One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 42 | \item{full_result}{One or more character strings comprised `estimate` and `statistic`. A single string is returned in a vector; multiple strings are returned as a named list. } 43 | \item{table}{A \code{data.frame} of class \code{apa_results_table} that contains all elements of \code{estimate} and \code{statistics}. This table can be passed to \code{apa_table()} for reporting.} 44 | 45 | Column names in \code{apa_results_table} are standardized following the \href{https://www.tidymodels.org/learn/develop/broom/#glossary}{\pkg{broom} glossary} (e.g., \code{term}, \code{estimate} \code{conf.int}, \code{statistic}, \code{df}, \code{df.residual}, \code{p.value}). Additionally, each column is labelled (e.g., \code{$\\hat{\\eta}^2_G$} or \code{$t$}) using the \pkg{tinylabels} package and these labels are used as column names when an \code{apa_results_table} is passed to \code{apa_table()}. 46 | 47 | } 48 | -------------------------------------------------------------------------------- /man/apa_print.glht.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_print_glht.R 3 | \name{apa_print.glht} 4 | \alias{apa_print.glht} 5 | \alias{apa_print.summary.glht} 6 | \title{Typeset Statistical Results from General Linear Hypothesis Tests} 7 | \usage{ 8 | \method{apa_print}{glht}(x, test = multcomp::adjusted(), ...) 9 | 10 | \method{apa_print}{summary.glht}(x, conf.int = 0.95, in_paren = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{x}{Object} 14 | 15 | \item{test}{Function. Computes p-values (adjusted for multiple comparisons).} 16 | 17 | \item{...}{Further arguments to pass to \code{\link{apa_num}} to format the estimate.} 18 | 19 | \item{conf.int}{Numeric. If \code{NULL} (default) the function tries to obtain confidence intervals from \code{x}. 20 | Other confidence intervals can be supplied as a \code{vector} of length 2 (lower and upper boundary, respectively) 21 | with attribute \code{conf.level}, e.g., when calculating bootstrapped confidence intervals.} 22 | 23 | \item{in_paren}{Logical. Whether the formatted string is to be reported in 24 | parentheses. If \code{TRUE}, parentheses in the formatted string (e.g., those 25 | enclosing degrees of freedom) are replaced with brackets.} 26 | } 27 | \description{ 28 | \emph{These methods are not properly tested and should be 29 | considered experimental.} 30 | } 31 | \examples{ 32 | # From the multcomp::glht() examples: 33 | library(multcomp) 34 | amod <- aov(breaks ~ tension, data = warpbreaks) 35 | glht_out <- glht(amod, linfct = mcp(tension = "Tukey")) 36 | apa_print(glht_out) 37 | 38 | # In this example, because degrees of freedom are equal across all rows 39 | # of the output, it is possible to move that information to the variable 40 | # labels. This is useful if a compact results table is required: 41 | 42 | df_into_label(apa_print(glht_out)) 43 | } 44 | \seealso{ 45 | Other apa_print: 46 | \code{\link{apa_print}()}, 47 | \code{\link{apa_print.BFBayesFactor}()}, 48 | \code{\link{apa_print.aov}()}, 49 | \code{\link{apa_print.emmGrid}()}, 50 | \code{\link{apa_print.htest}()}, 51 | \code{\link{apa_print.list}()}, 52 | \code{\link{apa_print.lm}()}, 53 | \code{\link{apa_print.lme}()}, 54 | \code{\link{apa_print.merMod}()} 55 | } 56 | \concept{apa_print} 57 | \value{ 58 | \code{apa_print()}-methods return a named list of class \code{apa_results} containing the following elements: 59 | 60 | \item{estimate}{One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 61 | \item{statistic}{One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 62 | \item{full_result}{One or more character strings comprised `estimate` and `statistic`. A single string is returned in a vector; multiple strings are returned as a named list. } 63 | \item{table}{A \code{data.frame} of class \code{apa_results_table} that contains all elements of \code{estimate} and \code{statistics}. This table can be passed to \code{apa_table()} for reporting.} 64 | 65 | Column names in \code{apa_results_table} are standardized following the \href{https://www.tidymodels.org/learn/develop/broom/#glossary}{\pkg{broom} glossary} (e.g., \code{term}, \code{estimate} \code{conf.int}, \code{statistic}, \code{df}, \code{df.residual}, \code{p.value}). Additionally, each column is labelled (e.g., \code{$\\hat{\\eta}^2_G$} or \code{$t$}) using the \pkg{tinylabels} package and these labels are used as column names when an \code{apa_results_table} is passed to \code{apa_table()}. 66 | 67 | } 68 | -------------------------------------------------------------------------------- /man/apa_print.lme.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_print_nlme.R 3 | \name{apa_print.lme} 4 | \alias{apa_print.lme} 5 | \alias{apa_print.anova.lme} 6 | \title{Typeset Statistical Results from Nonlinear Hierarchical Models} 7 | \usage{ 8 | \method{apa_print}{lme}(x, conf.int = 0.95, in_paren = FALSE, est_name = NULL, ...) 9 | 10 | \method{apa_print}{anova.lme}(x, in_paren = FALSE, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A (non-)linear mixed-effects model fitted with \code{\link[nlme:lme]{nlme::lme()}} or 14 | \code{\link[nlme:nlme]{nlme::nlme()}}} 15 | 16 | \item{conf.int}{Numeric specifying the required confidence level \emph{or} a named list 17 | of additional arguments that are passed to \code{\link[nlme:intervals.lme]{nlme::intervals.lme()}}.} 18 | 19 | \item{in_paren}{Logical. Whether the formatted string is to be reported in 20 | parentheses. If \code{TRUE}, parentheses in the formatted string (e.g., those 21 | enclosing degrees of freedom) are replaced with brackets.} 22 | 23 | \item{est_name}{An optional character. The label to be used for 24 | fixed-effects coefficients.} 25 | 26 | \item{...}{Further arguments that may be passed to \code{\link{apa_num}} to format estimates (i.e., columns \code{estimate} and \code{conf.int}).} 27 | } 28 | \description{ 29 | These methods take mixed-effects models fitted with the \pkg{nlme} package 30 | and create formatted character strings report the results in accordance 31 | with APA manuscript guidelines. 32 | } 33 | \examples{ 34 | library(nlme) 35 | fm1 <- lme(distance ~ age, data = Orthodont, method = "ML") # random is ~ age 36 | apa_print(fm1, conf.int = .9) 37 | # ANOVA-like tables 38 | single_anova <- anova(fm1) 39 | apa_print(single_anova) 40 | 41 | } 42 | \seealso{ 43 | Other apa_print: 44 | \code{\link{apa_print}()}, 45 | \code{\link{apa_print.BFBayesFactor}()}, 46 | \code{\link{apa_print.aov}()}, 47 | \code{\link{apa_print.emmGrid}()}, 48 | \code{\link{apa_print.glht}()}, 49 | \code{\link{apa_print.htest}()}, 50 | \code{\link{apa_print.list}()}, 51 | \code{\link{apa_print.lm}()}, 52 | \code{\link{apa_print.merMod}()} 53 | } 54 | \concept{apa_print} 55 | \value{ 56 | \code{apa_print()}-methods return a named list of class \code{apa_results} containing the following elements: 57 | 58 | \item{estimate}{One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 59 | \item{statistic}{One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 60 | \item{full_result}{One or more character strings comprised `estimate` and `statistic`. A single string is returned in a vector; multiple strings are returned as a named list. } 61 | \item{table}{A \code{data.frame} of class \code{apa_results_table} that contains all elements of \code{estimate} and \code{statistics}. This table can be passed to \code{apa_table()} for reporting.} 62 | 63 | Column names in \code{apa_results_table} are standardized following the \href{https://www.tidymodels.org/learn/develop/broom/#glossary}{\pkg{broom} glossary} (e.g., \code{term}, \code{estimate} \code{conf.int}, \code{statistic}, \code{df}, \code{df.residual}, \code{p.value}). Additionally, each column is labelled (e.g., \code{$\\hat{\\eta}^2_G$} or \code{$t$}) using the \pkg{tinylabels} package and these labels are used as column names when an \code{apa_results_table} is passed to \code{apa_table()}. 64 | 65 | } 66 | -------------------------------------------------------------------------------- /man/apa_print.papaja_wsci.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_print_wsci.R 3 | \name{apa_print.papaja_wsci} 4 | \alias{apa_print.papaja_wsci} 5 | \title{Typeset Within-Subjects Confidence Intervals} 6 | \usage{ 7 | \method{apa_print}{papaja_wsci}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object of class \code{papaja_wsci}.} 11 | 12 | \item{...}{ 13 | Arguments passed on to \code{\link[=apa_num.numeric]{apa_num.numeric}} 14 | \describe{ 15 | \item{\code{gt1}}{Logical. Indicates if the statistic can, in principle, have an 16 | absolute value greater than 1. If \code{FALSE}, leading zeros are 17 | omitted.} 18 | \item{\code{zero}}{Logical. Indicates if the statistic can, in principle, be 0. If 19 | \code{FALSE}, a string of the form \verb{< 0.001} is returned instead of 0.} 20 | \item{\code{na_string}}{Character. String to print if any element of \code{x} is \code{NA}.} 21 | \item{\code{use_math}}{Logical. Indicates whether to use \code{$} in the output so that 22 | \code{Inf} or scientific notation is rendered correctly.} 23 | \item{\code{add_equals}}{Logical. Indicates if the output string should be 24 | prepended with an \code{=}.} 25 | }} 26 | } 27 | \description{ 28 | This method takes an output object from \code{\link{wsci}} and creates a 29 | table and character strings to report means and within-subjects confidence 30 | intervals in a table or in text. 31 | } 32 | \value{ 33 | \code{apa_print()}-methods return a named list of class \code{apa_results} containing the following elements: 34 | 35 | \item{estimate}{One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 36 | \item{statistic}{One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is \code{NULL}.} 37 | \item{full_result}{One or more character strings comprised `estimate` and `statistic`. A single string is returned in a vector; multiple strings are returned as a named list. } 38 | \item{table}{A \code{data.frame} of class \code{apa_results_table} that contains all elements of \code{estimate} and \code{statistics}. This table can be passed to \code{apa_table()} for reporting.} 39 | 40 | Column names in \code{apa_results_table} are standardized following the \href{https://www.tidymodels.org/learn/develop/broom/#glossary}{\pkg{broom} glossary} (e.g., \code{term}, \code{estimate} \code{conf.int}, \code{statistic}, \code{df}, \code{df.residual}, \code{p.value}). Additionally, each column is labelled (e.g., \code{$\\hat{\\eta}^2_G$} or \code{$t$}) using the \pkg{tinylabels} package and these labels are used as column names when an \code{apa_results_table} is passed to \code{apa_table()}. 41 | 42 | } 43 | -------------------------------------------------------------------------------- /man/arrange_anova.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/arrange_anova.R 3 | \name{arrange_anova} 4 | \alias{arrange_anova} 5 | \alias{arrange_anova.anova} 6 | \alias{arrange_anova.summary.aov} 7 | \alias{arrange_anova.summary.Anova.mlm} 8 | \title{Create Variance Table from Various ANOVA objects} 9 | \usage{ 10 | arrange_anova(x, ...) 11 | 12 | \method{arrange_anova}{anova}(x, ...) 13 | 14 | \method{arrange_anova}{summary.aov}(x, ...) 15 | 16 | \method{arrange_anova}{summary.Anova.mlm}(x, correction = "GG", ...) 17 | } 18 | \arguments{ 19 | \item{x}{Output object. See details.} 20 | 21 | \item{...}{Further arguments to pass to methods.} 22 | 23 | \item{correction}{Character. For \code{summary.Anova.mlm} objects, specifies the type of 24 | sphericity correction to be used. Either \code{GG} for Greenhouse-Geisser or \code{HF} 25 | for Huyn-Feldt methods or \code{none} is also possible. Ignored for other objects.} 26 | } 27 | \value{ 28 | \code{data.frame} of class \code{apa_variance_table} or \code{apa_model_comp}. 29 | } 30 | \description{ 31 | These methods take objects from various R functions that calculate ANOVA to create 32 | a \code{data.frame} containing a variance table. \emph{This function is not exported 33 | and will most likely be deprecated, soon.} 34 | } 35 | \details{ 36 | The returned \code{data.frame} can be passed to functions such as \code{\link[=print_anova]{print_anova()}}. 37 | 38 | Currently, methods for the following objects are available: 39 | \itemize{ 40 | \item summary.aov 41 | \item summary.aovlist 42 | \item Anova.mlm 43 | } 44 | } 45 | \seealso{ 46 | \code{\link[=print_anova]{print_anova()}}, \code{\link[=print_model_comp]{print_model_comp()}} 47 | } 48 | \keyword{internal} 49 | -------------------------------------------------------------------------------- /man/arrange_regression.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_defunct.R 3 | \name{arrange_regression} 4 | \alias{arrange_regression} 5 | \title{Create a Regression Table (defunct)} 6 | \usage{ 7 | arrange_regression(x, est_name, standardized, conf.int, ...) 8 | } 9 | \arguments{ 10 | \item{x}{\code{glm} or \code{lm} object. See details.} 11 | 12 | \item{est_name}{Character. If \code{NULL} (the default) the name given in \code{x} 13 | (or a formally correct adaptation, such as "\eqn{b^*}" instead of "b" for 14 | standardized regression coefficients) is used. Otherwise the supplied name 15 | is used. See details.} 16 | 17 | \item{standardized}{Logical. Indicates if coefficients were standardized 18 | (e.g., using \code{scale()}), and leading zeros should be omitted if 19 | appropriate. See details.} 20 | 21 | \item{conf.int}{Numeric. Either a single value (range [0, 1]) giving the 22 | confidence level or a two-column \code{matrix} with confidence region bounds as 23 | column names (e.g. \code{"2.5 \%"} and \code{"97.5 \%"}) and coefficient names as row 24 | names (in the same order as they appear in \code{summary(x)$coefficients}. 25 | See details.} 26 | 27 | \item{...}{[\code{expressions}]\cr Unnamed arguments are taken to be expression 28 | string(s) to format. Multiple inputs are concatenated together before formatting. 29 | Named arguments are taken to be temporary variables available for substitution. 30 | 31 | For \code{glue_data()}, elements in \code{...} override the values in \code{.x}.} 32 | } 33 | \value{ 34 | \code{data.frame} of class \code{apa_regression_table}. 35 | } 36 | \description{ 37 | These methods take \code{glm} or \code{lm} objects to create 38 | a data frame containing a regression table. 39 | \emph{This function has been defunct. It is 40 | no longer needed.} 41 | } 42 | \keyword{internal} 43 | -------------------------------------------------------------------------------- /man/beautify.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{beautify} 4 | \alias{beautify} 5 | \title{Beautify a Canonical Table} 6 | \usage{ 7 | beautify(x, standardized = FALSE, use_math = FALSE, args_stat = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An object created by \code{\link{canonize}}.} 11 | 12 | \item{standardized}{Logical. If TRUE the name of the function \code{scale} will be removed from term names.} 13 | 14 | \item{...}{Further arguments that may be passed to \code{\link{apa_num}} to format estimates (i.e., columns \code{estimate} and \code{conf.int}).} 15 | } 16 | \description{ 17 | Internal function that takes an object created by \code{\link[=canonize]{canonize()}} and 18 | applies proper rounding. Term names are beautified by removing parentheses and replacing 19 | colons with \code{"$\\\\times$"}. Moreover, both rows and columns are sorted. 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/beautify_terms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_text.R 3 | \name{beautify_terms} 4 | \alias{beautify_terms} 5 | \alias{beautify_terms.character} 6 | \alias{beautify_terms.numeric} 7 | \alias{beautify_terms.factor} 8 | \alias{beautify_terms.data.frame} 9 | \title{Prettify Term Names} 10 | \usage{ 11 | beautify_terms(x, ...) 12 | 13 | \method{beautify_terms}{character}(x, standardized = FALSE, retain_period = FALSE, ...) 14 | 15 | \method{beautify_terms}{numeric}(x, standardized = FALSE, ...) 16 | 17 | \method{beautify_terms}{factor}(x, standardized = FALSE, ...) 18 | 19 | \method{beautify_terms}{data.frame}(x, ...) 20 | } 21 | \arguments{ 22 | \item{x}{Character. Vector of term names to be prettified.} 23 | 24 | \item{...}{Additional arguments passed to \code{\link[=apa_num]{apa_num()}}, for numeric values in 25 | \code{x}, ignored otherwise.} 26 | 27 | \item{standardized}{Logical. If \code{TRUE}, the name of the function \code{\link[=scale]{scale()}} will be 28 | removed from term names.} 29 | 30 | \item{retain_period}{Logical. If \code{TRUE}, any periods in term names will be 31 | retained, otherwise they will be replaced by a space.} 32 | } 33 | \value{ 34 | A character vector or \code{data.frame} (if \code{x} is a \code{data.frame}) 35 | containing term names modified for nicer printing. 36 | } 37 | \description{ 38 | Remove parentheses, replace colons with \code{$\\times$}. 39 | Useful to prettify term names in \code{\link[=apa_print]{apa_print()}} tables. 40 | } 41 | \examples{ 42 | beautify_terms("a:b") 43 | beautify_terms("scale(x)", standardized = TRUE) 44 | beautify_terms("snake_case") 45 | } 46 | -------------------------------------------------------------------------------- /man/brighten.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_plot.R 3 | \name{brighten} 4 | \alias{brighten} 5 | \title{Brighten up a Color} 6 | \usage{ 7 | brighten(col, factor) 8 | } 9 | \arguments{ 10 | \item{col}{Colour to be brightened up. Can be anything that is digestible by \code{\link[=col2rgb]{col2rgb()}}.} 11 | 12 | \item{factor}{Numeric. The rate with which the color channel should be boosted. Must be in the range between 0 and 1.} 13 | } 14 | \value{ 15 | A character vector as returned by \code{\link[=rgb]{rgb()}}. 16 | } 17 | \description{ 18 | Brighten up a specified color (e.g., the swarm color in \code{\link[=apa_beeplot]{apa_beeplot()}}). 19 | \emph{This function is not exported.} 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/canonize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{canonize} 4 | \alias{canonize} 5 | \title{Transform to a Canonical Table} 6 | \usage{ 7 | canonize(x, stat_label = NULL, est_label = NULL, interval_type = "CI") 8 | } 9 | \arguments{ 10 | \item{x}{A data frame.} 11 | 12 | \item{stat_label}{Character. Label for column \code{statistic}.} 13 | 14 | \item{est_label}{Character. Label for column \code{estimate}.} 15 | } 16 | \description{ 17 | Internal function that puts a data frame into a canonical structure by 18 | renaming and labelling columns. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/cite_r.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cite_r.R 3 | \name{cite_r} 4 | \alias{cite_r} 5 | \title{Cite R and R Packages} 6 | \usage{ 7 | cite_r( 8 | file = NULL, 9 | prefix = "R-", 10 | footnote = FALSE, 11 | pkgs = NULL, 12 | omit = TRUE, 13 | lang = NULL, 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{file}{Character. Path and name of the \code{.bib}-file holding the 19 | references. If \code{NULL}, only R is cited.} 20 | 21 | \item{prefix}{Character. Prefix used for all R-package reference handles.} 22 | 23 | \item{footnote}{Logical. Indicates if packages should be cited in a 24 | footnote. Ignored if no package information is available.} 25 | 26 | \item{pkgs}{Character. Vector of package names to cite or omit depending 27 | on \code{omit}.} 28 | 29 | \item{omit}{Logical. If \code{TRUE}, \code{pkgs} constitutes a list of packages 30 | \emph{not} to cite (a blacklist). If \code{FALSE}, \code{pkgs} constitutes a list of 31 | packages to cite (a whitelist).} 32 | 33 | \item{lang}{Character. Language code according to BCP 47. If \code{NULL}, the 34 | defaults to the language set in the YAML front matter or to English.} 35 | 36 | \item{...}{Additional arguments, which are currently ignored.} 37 | } 38 | \value{ 39 | If \code{footnote = FALSE} a character string is returned, otherwise a 40 | named list with the elements \code{r} and \code{pkgs}. 41 | } 42 | \description{ 43 | Creates character strings to cite R and R packages. 44 | } 45 | \details{ 46 | If \code{footnote = FALSE}, a character string citing R and R packages 47 | including version numbers is returned. Otherwise a named list with the 48 | elements \code{r} and \code{pkgs} is returned. The former element holds a character 49 | string citing R and a reference to a footnote; the latter element contains 50 | a character string that creates the footnote. For correct rendering, the 51 | footnote string needs to be a separate paragraph in the R Markdown 52 | document. 53 | } 54 | \examples{ 55 | cite_r() 56 | } 57 | \seealso{ 58 | \code{\link[=r_refs]{r_refs()}}, \code{\link[knitr:write_bib]{knitr::write_bib()}} 59 | } 60 | -------------------------------------------------------------------------------- /man/combine_plotmath.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_plot.R 3 | \name{combine_plotmath} 4 | \alias{combine_plotmath} 5 | \title{Combine to Expression} 6 | \usage{ 7 | combine_plotmath(x) 8 | } 9 | \arguments{ 10 | \item{x}{A \code{list} that contains all elements that are intended to be coerced into one expression.} 11 | } 12 | \value{ 13 | An expression 14 | } 15 | \description{ 16 | We use this internal function to generate expressions that can be used for plotting. Accepts a list of elements that are coerced, 17 | currently supported elements are \code{character}, \code{expression}, and \code{character} that contain \code{latex} elements. 18 | \emph{This function is not exported.} 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/complete_observations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{complete_observations} 4 | \alias{complete_observations} 5 | \title{Remove Incomplete Observations from Data Frame} 6 | \usage{ 7 | complete_observations(data, id, within, dv) 8 | } 9 | \arguments{ 10 | \item{data}{The \code{data.frame} to be processed.} 11 | 12 | \item{id}{Character. Name of the column containing the subject identifier.} 13 | 14 | \item{within}{Character. Names of the columns containing within-subjects factors.} 15 | 16 | \item{dv}{Character. Name of the column containing the dependent variable.} 17 | } 18 | \value{ 19 | A \code{data.frame} where NAs and incomplete observations are removed. 20 | It also has up to two additional attributes \code{removed_cases_explicit_NA} 21 | and \code{removed_cases_implicit_NA}, carrying the subject identifiers of 22 | participants whose data has been removed. 23 | } 24 | \description{ 25 | This is an internal function that is used to remove incomplete observations 26 | from a \code{data.frame}. It removes (1) explicit NAs and (2) cases with 27 | implicit NAs, i.e. participants who did not provide observations for all 28 | combinations of (possibly multiple) within-subjects factors. 29 | } 30 | \keyword{internal} 31 | -------------------------------------------------------------------------------- /man/conf_int.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calculations.R 3 | \name{conf_int} 4 | \alias{conf_int} 5 | \alias{conf.int} 6 | \alias{ci} 7 | \title{Between-Subjects Confidence Intervals} 8 | \usage{ 9 | conf_int(x, level = 0.95, na.rm = TRUE) 10 | 11 | conf.int(x, level = 0.95, na.rm = TRUE) 12 | 13 | ci(x, level = 0.95, na.rm = TRUE) 14 | } 15 | \arguments{ 16 | \item{x}{Numeric. A vector of observations from your dependent variable.} 17 | 18 | \item{level}{Numeric. Defines the width of the interval if confidence intervals are plotted. Defaults to 0.95 19 | for 95\% confidence intervals.} 20 | 21 | \item{na.rm}{Logical. Specifies if missing values should be removed.} 22 | } 23 | \value{ 24 | Returns a single numeric value, the deviation of the symmetric 25 | confidence bounds from the mean based on the t distribution. 26 | } 27 | \description{ 28 | Calculates the deviation that is needed to construct confidence intervals for a vector of observations. 29 | } 30 | -------------------------------------------------------------------------------- /man/corresponding_author_line.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/word_title_page.R 3 | \name{corresponding_author_line} 4 | \alias{corresponding_author_line} 5 | \title{Corresponding-Author Line} 6 | \usage{ 7 | corresponding_author_line(x) 8 | } 9 | \arguments{ 10 | \item{x}{List. Meta data of the document as a result from \code{\link[yaml:yaml.load]{yaml::yaml.load()}}.} 11 | } 12 | \description{ 13 | Internal function. Construct corresponding-author line. 14 | } 15 | \keyword{internal} 16 | -------------------------------------------------------------------------------- /man/default_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variable_label.R 3 | \name{default_label} 4 | \alias{default_label} 5 | \alias{default_label.default} 6 | \alias{default_label.data.frame} 7 | \title{Set Default Variable Labels from Column Names} 8 | \usage{ 9 | default_label(x, ...) 10 | 11 | \method{default_label}{default}(x, ...) 12 | 13 | \method{default_label}{data.frame}(x, ...) 14 | } 15 | \arguments{ 16 | \item{x}{A \code{data.frame}} 17 | } 18 | \value{ 19 | Returns a \code{data.frame} with labelled columns. Labels are preserved (if already specified), otherwise generated from column names. 20 | } 21 | \description{ 22 | This internal function creates variable labels from the column names of a1 23 | data frame. 24 | } 25 | \keyword{internal} 26 | -------------------------------------------------------------------------------- /man/defaults.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{defaults} 4 | \alias{defaults} 5 | \title{Set Defaults} 6 | \usage{ 7 | defaults(ellipsis, set = NULL, set.if.null = NULL) 8 | } 9 | \arguments{ 10 | \item{ellipsis}{A \code{list}, usually a list that comes from an ellipsis} 11 | 12 | \item{set}{A named \code{list} of parameters that are intended to be set.} 13 | 14 | \item{set.if.null}{A named \code{list} of parameters that are intended to be set if and only if the parameter is not already in \code{ellipsis}.} 15 | } 16 | \description{ 17 | A helper function that is intended for internal use. A list \code{ellipsis} may be manipulated by overwriting (via \code{set}) or adding (via \code{set.if.null}) list elements. 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/escape_latex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_text.R 3 | \name{escape_latex} 4 | \alias{escape_latex} 5 | \title{Escape Symbols for LaTeX Output} 6 | \usage{ 7 | escape_latex(x, newlines = FALSE, spaces = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{Character.} 11 | 12 | \item{newlines}{Logical. Determines if \code{\\n} are escaped.} 13 | 14 | \item{spaces}{Logical. Determines if multiple spaces are escaped.} 15 | } 16 | \description{ 17 | This function is a copy of the non-exported function \code{escape_latex()} from the \pkg{knitr} package. 18 | \emph{This function is not exported.} 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/extract_apa_results_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_results_table.R 3 | \name{$.apa_results_table} 4 | \alias{$.apa_results_table} 5 | \alias{[[.apa_results_table} 6 | \alias{[.apa_results_table} 7 | \title{Extract Parts of an APA Results Table} 8 | \usage{ 9 | \method{$}{apa_results_table}(x, name) 10 | 11 | \method{[[}{apa_results_table}(x, i, exact = TRUE) 12 | 13 | \method{[}{apa_results_table}(x, i, j, ..., drop = TRUE) 14 | } 15 | \arguments{ 16 | \item{x}{Object from which to extract element(s).} 17 | 18 | \item{name}{ 19 | a literal character string or a \link[base]{name} (possibly \link[base]{backtick} 20 | quoted). For extraction, this is normally (see under 21 | \sQuote{Environments}) partially matched to the \code{\link[base]{names}} 22 | of the object. 23 | } 24 | 25 | \item{i, j, ...}{Indices specifying elements to extract. See \code{\link[base:Extract]{base::Extract()}} for details.} 26 | 27 | \item{exact}{controls possible partial matching of \code{[[} when 28 | extracting by a character vector (for most objects, but see under 29 | \sQuote{Environments}). The default is no partial matching. Value 30 | \code{NA} allows partial matching but issues a warning when it 31 | occurs. Value \code{FALSE} allows partial matching without any 32 | warning.} 33 | 34 | \item{drop}{relevant for matrices and arrays. If \code{TRUE} the result is 35 | coerced to the lowest possible dimension (see the examples). This 36 | only works for extracting elements, not for the replacement. See 37 | \code{\link[base]{drop}} for further details. 38 | } 39 | } 40 | \value{ 41 | A (vector of) character values as extracted from an object of class 42 | \code{apa_results_table}. 43 | } 44 | \description{ 45 | \emph{These methods are only defined for backward compatibility with older 46 | versions of \pkg{papaja}}. In the past, the column names of\code{apa_results_table}s 47 | were less standardized than they are today. In order to maintain backwards 48 | compatibility, it is still possible to extract columns with the old columns names, 49 | because we here provide \emph{aliased} indexing. Note that aliased indexing will be 50 | defunct in a future release of \pkg{papaja}. 51 | } 52 | -------------------------------------------------------------------------------- /man/fast_aggregate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fast_aggregate.R 3 | \name{fast_aggregate} 4 | \alias{fast_aggregate} 5 | \title{Aggregate data much faster using dplyr} 6 | \usage{ 7 | fast_aggregate(data, factors, dv, fun, na.rm = TRUE) 8 | } 9 | \arguments{ 10 | \item{data}{A \code{data.frame} that contains the data.} 11 | 12 | \item{factors}{Character. A vector of factor names to aggregate data by.} 13 | 14 | \item{dv}{Character. The dependent variable to aggregate. All variables in \code{data} that contain this character string 15 | will be aggregated separately.} 16 | 17 | \item{fun}{Closure. The function used for aggregation.} 18 | } 19 | \description{ 20 | This is a convenience wrapper for aggregating your data using \pkg{dplyr} functions that tend to be much faster than the 21 | usual \code{\link[stats:aggregate]{stats::aggregate()}} command. It is also easy to call from within a function. \emph{This function is not exported.} 22 | } 23 | \keyword{internal} 24 | -------------------------------------------------------------------------------- /man/fetch_web_refs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_defunct.R 3 | \name{fetch_web_refs} 4 | \alias{fetch_web_refs} 5 | \title{Fetch a .bib-reference file from the web (defunct)} 6 | \usage{ 7 | fetch_web_refs(x, bib_name) 8 | } 9 | \arguments{ 10 | \item{x}{Character. URL of the \code{.bib}-file to fetch.} 11 | 12 | \item{bib_name}{Character. The path and name of the file to be created.} 13 | } 14 | \value{ 15 | Returns \code{NULL} invisibly. 16 | } 17 | \description{ 18 | Downloads and saves a \code{.bib}-reference file form the web, so it can be 19 | used to cite references in a Markdown-document using pandoc or LaTeX. 20 | \emph{This function has been defunct. Please use \code{download} from the 21 | \pkg{downloader} instead.} 22 | } 23 | \details{ 24 | If the function is called in an RMarkdown-document the file name 25 | specified as \code{bib_name} can be used in the YAML header as 26 | \code{bibliography}. 27 | } 28 | \seealso{ 29 | \code{\link[=cite_r]{cite_r()}}, \code{\link[=r_refs]{r_refs()}}, \code{\link[knitr:write_bib]{knitr::write_bib()}} 30 | } 31 | -------------------------------------------------------------------------------- /man/fetch_zotero_refs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_defunct.R 3 | \name{fetch_zotero_refs} 4 | \alias{fetch_zotero_refs} 5 | \title{Save a collection from a Zotero-Account to a BibTeX-file (defunct)} 6 | \usage{ 7 | fetch_zotero_refs( 8 | x, 9 | bib_name, 10 | API_key = NULL, 11 | collection = NULL, 12 | lib_type = "user" 13 | ) 14 | } 15 | \arguments{ 16 | \item{x}{Character. Zotero user or group ID, see details.} 17 | 18 | \item{bib_name}{Character. Name of the BibTeX-file references are saved to.} 19 | 20 | \item{API_key}{Character. Zotero API key, see details.} 21 | 22 | \item{collection}{Character. Optional ID of a collection in the Zotero 23 | library, see details.} 24 | 25 | \item{lib_type}{Character. Specifies if the supplied ID is associated with a 26 | Zotero \code{user} or \code{group}.} 27 | } 28 | \value{ 29 | Returns \code{bib_name} invisibly. 30 | } 31 | \description{ 32 | Downloads and saves a Zotero reference library (or a subset) and saves it as 33 | BibTeX file. \emph{This function has been defunct. Use \code{ReadZotero()} from the 34 | \pkg{RefManageR} package instead.} 35 | } 36 | \details{ 37 | This function retrieves references through the Zotero web API. \code{x} 38 | takes a Zotero user or group ID that can be retrieved from the Zotero.org 39 | user or group Feeds/API settings. 40 | An authentication key (\code{API_key}) is required to access nonpublic 41 | Zotero libraries. Authentication keys can also be generated in the 42 | Zotero.org user or group Feeds/API settings. 43 | 44 | If the requested reference collection is larger than 100 records, multiple 45 | API calls are initiated because the number of retrieved records is limited 46 | to 100 per API call. Frequent API calls will result in a temporary access 47 | block. Thus, there is an (currently unknown) upper limit to the length of 48 | reference collections that can be retrieved through this function. It is 49 | generally recommended to comment out calls to this function in R 50 | Markdown documents during periods of frequent knitting to limit the number 51 | of API calls and limit the number of references to those needed for the 52 | current document by setting up collections in your Zotero library. 53 | 54 | Collection keys (\code{collection}), i.e. identifiers of reference library 55 | subsets, can be retrieved by accessing them via a web browser. They keys 56 | are contained in the URL: 57 | 58 | \verb{https://www.zotero.org//items/collectionKey/} 59 | 60 | Zotero web API calls can be slow, especially for large reference 61 | collections. If available, this function will use the 62 | \pkg{downloader}-package, which speeds up reference downloads considerably. 63 | } 64 | \seealso{ 65 | \code{\link[=cite_r]{cite_r()}}, \code{\link[=r_refs]{r_refs()}} 66 | } 67 | \author{ 68 | Christoph Stahl, Frederik Aust 69 | } 70 | -------------------------------------------------------------------------------- /man/figures/theme_apa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/man/figures/theme_apa.png -------------------------------------------------------------------------------- /man/format_cells.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_table.R 3 | \name{format_cells} 4 | \alias{format_cells} 5 | \title{Format numeric table cells} 6 | \usage{ 7 | format_cells(x, format.args = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{data.frame or matrix.} 11 | 12 | \item{format.args}{List. A named list of arguments to be passed to \code{\link{apa_num}} to format numeric values.} 13 | } 14 | \description{ 15 | Format all numeric cells of a table using \code{\link{apa_num}}. 16 | \emph{This function is not exported.} 17 | } 18 | \seealso{ 19 | \code{\link[=apa_num]{apa_num()}} 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/generate_author_yml.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_author_yml.R 3 | \name{generate_author_yml} 4 | \alias{generate_author_yml} 5 | \title{generate_author_yml} 6 | \usage{ 7 | generate_author_yml( 8 | researchers, 9 | affiliations, 10 | corres_name, 11 | corres_address, 12 | corres_email 13 | ) 14 | } 15 | \arguments{ 16 | \item{researchers}{a list of named character vectors. Author information is stored in the name of the vector. Abbreviated affiliations are stored in the vector.} 17 | 18 | \item{affiliations}{a list of named character strings. Abbreviated affiliations are stored in the names, the full affiliation is stored in the string.} 19 | 20 | \item{corres_name}{A character string. The name of the corresponding author, must match the author details in the researcher argument identically.} 21 | 22 | \item{corres_address}{A character string. The address of the corresponding author} 23 | 24 | \item{corres_email}{A character string. The email of the corresponding author.} 25 | } 26 | \description{ 27 | This function helps organize YAML author and affiliation fields such that authorship order can be changed without having to also update the order of affiliations. 28 | } 29 | \examples{ 30 | 31 | library(papaja) 32 | 33 | generate_author_yml ( 34 | researchers = list( 35 | "Emma J. Citizen" = c("example_hospital", "example_college"), 36 | "John H. Smith" = "example_college", 37 | "Kate C. Jones" = "example_hospital" 38 | ), 39 | affiliations = list( 40 | "example_hospital" = "Southern Example Hospital, NSW, Australia", 41 | "example_college" = "New Example College, VIC, Australia" 42 | ), 43 | corres_name = "Emma J. Citizen", 44 | corres_address = "123 Example Street, Epping, NSW 2121", 45 | corres_email = "jane@example.com" 46 | ) 47 | } 48 | -------------------------------------------------------------------------------- /man/glue_apa_results.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/glue_apa_results.R 3 | \name{glue_apa_results} 4 | \alias{glue_apa_results} 5 | \alias{add_glue_to_apa_results} 6 | \title{Create a New \code{apa_results} Object} 7 | \usage{ 8 | glue_apa_results(x = NULL, term_names = NULL, ...) 9 | 10 | add_glue_to_apa_results( 11 | ..., 12 | est_glue, 13 | stat_glue, 14 | container, 15 | sublist = NULL, 16 | term_names = NULL, 17 | in_paren = FALSE, 18 | est_first = TRUE, 19 | simplify = TRUE 20 | ) 21 | } 22 | \arguments{ 23 | \item{x}{An environment, list or data frame used to look up values for 24 | substitution.} 25 | 26 | \item{term_names}{Character. Used as names for the \code{estimate}-, 27 | \code{statistics}-, and \code{full_result} sub-lists, if multiple estimates or 28 | statistics are glued. Defaults to \code{attr(x, "sanitized_term_names")}.} 29 | 30 | \item{...}{[\code{expressions}]\cr Unnamed arguments are taken to be expression 31 | string(s) to format. Multiple inputs are concatenated together before formatting. 32 | Named arguments are taken to be temporary variables available for substitution. 33 | 34 | For \code{glue_data()}, elements in \code{...} override the values in \code{.x}.} 35 | 36 | \item{est_glue}{Character. (Named vector of) expressions string(s) to 37 | format. Each string creates a new (named) element in the 38 | \code{estimate} sub-list.} 39 | 40 | \item{stat_glue}{Character. (Named vector of) expressions string(s) to 41 | format. Each string creates a new (named) element in the 42 | \code{statistic} sub-list.} 43 | 44 | \item{container}{List of class \code{apa_results} to add the glued results to.} 45 | 46 | \item{sublist}{Character. Name of (new) sub-list in \code{estimate} 47 | \code{statistics}, and \code{full_result} to append glued results to (e.g., 48 | \code{modelfit}).} 49 | 50 | \item{in_paren}{Logical. Whether the formatted string is to be reported in 51 | parentheses. If \code{TRUE}, parentheses in the formatted string (e.g., those 52 | enclosing degrees of freedom) are replaced with brackets.} 53 | 54 | \item{est_first}{Logical. Determines in which order \code{estimate} and 55 | \code{statistic} are glued together to \code{full_result}.} 56 | 57 | \item{simplify}{Logical. Determines whether the \code{estimate}, \code{statistic}, and 58 | \code{full_result} sub-lists should be simplified if only one term is 59 | available from the model object.} 60 | } 61 | \value{ 62 | Returns a list of class \code{apa_results}, see \code{\link[=apa_print]{apa_print()}}. 63 | } 64 | \description{ 65 | Typeset the contents of an object according to the specified expression 66 | strings and create a new or extend an existing \code{apa_results} object. 67 | } 68 | \examples{ 69 | # Tidy and typeset output 70 | iris_lm <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris) 71 | tidy_iris_lm <- broom::tidy(iris_lm, conf.int = TRUE) 72 | tidy_iris_lm$p.value <- apa_p(tidy_iris_lm$p.value) 73 | 74 | glance_iris_lm <- broom::glance(iris_lm) 75 | glance_iris_lm$p.value <- apa_p(glance_iris_lm$p.value, add_equals = TRUE) 76 | glance_iris_lm$df <- apa_num(as.integer(glance_iris_lm$df)) 77 | glance_iris_lm$df.residual <- apa_num(as.integer(glance_iris_lm$df.residual)) 78 | 79 | # Create `apa_results`-list 80 | lm_results <- glue_apa_results( 81 | x = tidy_iris_lm 82 | , df = glance_iris_lm$df.residual 83 | , est_glue = "$b = <>, 95\% CI $[<>,~<>]$" 84 | , stat_glue = "$t(<>) = <>$, $p <>$" 85 | , term_names = make.names(names(coef(iris_lm))) 86 | ) 87 | 88 | # Add modelfit information 89 | add_glue_to_apa_results( 90 | .x = glance_iris_lm 91 | , container = lm_results 92 | , sublist = "modelfit" 93 | , est_glue = c( 94 | r2 = "$R^2 = <>$" 95 | , aic = "" 96 | ) 97 | , stat_glue = c( 98 | r2 = "$F(<>, <>) = <>$, $p <>$" 99 | , aic = "$\\\\mathrm{AIC} = <>$" 100 | ) 101 | ) 102 | } 103 | -------------------------------------------------------------------------------- /man/hd_int.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calculations.R 3 | \name{hd_int} 4 | \alias{hd_int} 5 | \title{Highest-Density Intervals} 6 | \usage{ 7 | hd_int(x, level = 0.95) 8 | } 9 | \arguments{ 10 | \item{x}{Numeric. A vector of observations.} 11 | 12 | \item{level}{Numeric. Defines the width of the interval. Defaults to 95\% highest-density intervals.} 13 | } 14 | \description{ 15 | Calculates the highest-density interval of a vector of values. 16 | } 17 | -------------------------------------------------------------------------------- /man/in_paren.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/in_paren.R 3 | \name{in_paren} 4 | \alias{in_paren} 5 | \title{Replace Parentheses with Brackets} 6 | \usage{ 7 | in_paren(x) 8 | } 9 | \arguments{ 10 | \item{x}{Character. Single character or list of characters.} 11 | } 12 | \value{ 13 | An object of the same type as \code{x}, where all parentheses have been 14 | replaced by brackets. 15 | } 16 | \description{ 17 | Takes a single character or a list of characters and replaces parentheses 18 | with brackets. Can be used to prepare a string of statistics (e.g. containing 19 | degrees of freedom) for reporting within parentheses. 20 | } 21 | \examples{ 22 | t_stat <- t.test(extra ~ group, data = sleep) 23 | t_test_res <- apa_print(t_stat) 24 | in_paren(t_test_res$stat) 25 | in_paren(t_test_res[1:3]) 26 | } 27 | \seealso{ 28 | \code{\link[=apa_print]{apa_print()}} 29 | } 30 | -------------------------------------------------------------------------------- /man/indent_stubs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_table.R 3 | \name{indent_stubs} 4 | \alias{indent_stubs} 5 | \title{Add stub indentation} 6 | \usage{ 7 | indent_stubs(x, lines, filler = " ") 8 | } 9 | \arguments{ 10 | \item{x}{data.frame.} 11 | 12 | \item{lines}{List. A named list of vectors of length 2 giving the first and second row to 13 | indent. Names of list elements will be used as titles for indented sections.} 14 | 15 | \item{filler}{Character. Symbols used to indent stubs.} 16 | } 17 | \description{ 18 | Indents stubs by line and adds section headings 19 | \emph{This function is not exported.} 20 | } 21 | \seealso{ 22 | \code{\link[=apa_table]{apa_table()}} 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/init_apa_results.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{init_apa_results} 4 | \alias{init_apa_results} 5 | \title{Create Empty Container for Results} 6 | \usage{ 7 | init_apa_results() 8 | } 9 | \value{ 10 | A named list (with additional class \code{apa_results}) containing the following components: 11 | 12 | \describe{ 13 | \item{\code{estimate}}{A (named list of) character strings giving effect-size estimates.} 14 | \item{\code{statistic}}{A (named list of) character strings giving test statistic, parameters, and \emph{p} values.} 15 | \item{\code{full_result}}{A (named list of) character strings comprised of \code{estimate} and \code{statistic} for each factor.} 16 | \item{\code{table}}{A data frame containing all results; can, for example, be passed to \code{\link[=apa_table]{apa_table()}}.} 17 | } 18 | } 19 | \description{ 20 | Creates the default empty container for the results of \code{\link[=apa_print]{apa_print()}}. 21 | \emph{This function is not exported.} 22 | } 23 | \keyword{internal} 24 | -------------------------------------------------------------------------------- /man/lines.matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_plot.R 3 | \name{lines.matrix} 4 | \alias{lines.matrix} 5 | \title{Matrix Method for lines()} 6 | \usage{ 7 | \method{lines}{matrix}(x, y, type = "l", ...) 8 | } 9 | \description{ 10 | Internal function for convenient plotting of multiple lines. 11 | \emph{This function is not exported.} 12 | } 13 | \keyword{internal} 14 | -------------------------------------------------------------------------------- /man/localize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/lookup_tables.R 3 | \name{localize} 4 | \alias{localize} 5 | \title{Lookup Table for Generated Words and Phrases} 6 | \usage{ 7 | localize(x) 8 | } 9 | \arguments{ 10 | \item{x}{Integer. Locale.} 11 | } 12 | \description{ 13 | Some words and phrases used throughout a papaja manuscript are automatically 14 | generated and need to vary when the locale of a document is changed. This 15 | function returns the words and phrases by language. 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/lookup_tables.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/lookup_tables.R 3 | \docType{data} 4 | \name{lookup_names} 5 | \alias{lookup_names} 6 | \alias{lookup_labels} 7 | \alias{lookup_adjust_names} 8 | \title{Lookup Tables for Column Names and Variable Labels} 9 | \format{ 10 | An object of class \code{character} of length 116. 11 | 12 | An object of class \code{character} of length 110. 13 | } 14 | \usage{ 15 | lookup_names 16 | 17 | lookup_labels 18 | 19 | lookup_adjust_names(x) 20 | } 21 | \description{ 22 | \code{apa_print()} converts many statistical output objects to output objects that 23 | contain an \code{apa_results_table/data.frame} with standardized column names and 24 | variable labels. For this purpose, it relies on the lookup tables provided 25 | here. 26 | 27 | \code{apa_print()} converts many statistical output objects that include 28 | inferential statistics adjusted for multiple comparisons. To make these 29 | adjustments transparent the statistics get an index with the 30 | corresponding name. This function returns the proper names for these indices. 31 | } 32 | \keyword{internal} 33 | -------------------------------------------------------------------------------- /man/merge_tables.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_table.R 3 | \name{merge_tables} 4 | \alias{merge_tables} 5 | \title{Merge tables in list} 6 | \usage{ 7 | merge_tables(x, empty_cells, row_names, added_stub_head) 8 | } 9 | \arguments{ 10 | \item{x}{List. A named list containing one or more \code{matrix} or \code{data.frame}.} 11 | 12 | \item{empty_cells}{Character. String to place in empty cells; should be \code{""} if the target document is LaTeX and 13 | \code{" "} if the target document is Word.} 14 | 15 | \item{row_names}{Logical. Vector of boolean values specifying whether to print column names for the corresponding list 16 | element.} 17 | 18 | \item{added_stub_head}{Character. Vector of names for first unnamed columns. See \code{\link{apa_table}}.} 19 | } 20 | \description{ 21 | Takes a list of containing one or more \code{matrix} or \code{data.frame} and merges them into a single table. 22 | \emph{This function is not exported and currently unused.} 23 | } 24 | \seealso{ 25 | \code{\link[=apa_table]{apa_table()}} 26 | } 27 | \keyword{internal} 28 | -------------------------------------------------------------------------------- /man/package_available.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{package_available} 4 | \alias{package_available} 5 | \title{Package Available} 6 | \usage{ 7 | package_available(x) 8 | } 9 | \arguments{ 10 | \item{x}{Character. Name of the package to be checked.} 11 | } 12 | \value{ 13 | Logical. Is the specified package installed? 14 | } 15 | \description{ 16 | Internal function to check if a specified package is installed. 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/papaja.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/papaja.R 3 | \docType{package} 4 | \name{papaja} 5 | \alias{papaja-package} 6 | \alias{papaja} 7 | \title{Prepare APA Journal Articles with R Markdown} 8 | \description{ 9 | \code{papaja} is an \href{https://improvingpsych.org/mission/awards/}{award-winning} R package that facilitates creating computationally reproducible, submission-ready manuscripts which conform to the American Psychological Association (APA) manuscript guidelines (6th Edition). 10 | } 11 | \details{ 12 | \code{papaja} provides 13 | \itemize{ 14 | \item an \href{https://rmarkdown.rstudio.com/}{R Markdown} template that can be used with (or without) \href{https://posit.co/}{RStudio} to create PDF documents (using the \href{https://ctan.org/pkg/apa6}{apa6} LaTeX class) or Word documents (using a .docx-reference file). 15 | \item Functions to \emph{typeset} the results from \emph{statistical analyses} (e.g., \code{\link[=apa_print]{apa_print()}}), 16 | \item functions to create \emph{tables} (\code{\link[=apa_table]{apa_table()}}), and 17 | \item functions to create \emph{figures} in accordance with APA guidelines (e.g., \code{\link[=apa_factorial_plot]{apa_factorial_plot()}}). 18 | } 19 | } 20 | \section{System requirements}{ 21 | 22 | To use \code{papaja} you need either an up-to-date version of 23 | \href{https://posit.co/}{RStudio} or 24 | \href{https://pandoc.org/}{pandoc}. If you want to create PDF- 25 | in addition to DOCX-documents you additionally need a 26 | \href{https://en.wikipedia.org/wiki/TeX}{TeX} distribution. We recommend 27 | \href{https://yihui.org/tinytex/}{TinyTex}, which can be installed from within 28 | R via the \pkg{tinytex} package. 29 | 30 | Please refer to the \href{https://frederikaust.com/papaja_man/introduction.html#getting-started}{\code{papaja} manual} 31 | for detailed installation instructions. 32 | } 33 | 34 | \section{Getting help}{ 35 | 36 | For a comprehensive introduction to \code{papaja}, see the current draft of the \href{https://frederikaust.com/papaja_man/}{manual}. 37 | If you have a specific question that is not answered in the manual, feel free to ask a question on Stack Overflow \href{https://stackoverflow.com/questions/tagged/papaja}{using the \code{papaja} tag}. 38 | If you believe you have found a bug or would like to request a new feature, \href{https://github.com/crsh/papaja/issues}{open an issue} on Github and provide a \href{https://stackoverflow.com/help/minimal-reproducible-example}{minimal complete verifiable example}. 39 | } 40 | 41 | \section{Authors}{ 42 | 43 | Frederik Aust (frederik.aust at uni-koeln.de). 44 | Marius Barth (marius.barth at uni-koeln.de). 45 | } 46 | 47 | \section{Maintainer}{ 48 | 49 | Frederik Aust (frederik.aust at uni-koeln.de). 50 | } 51 | 52 | \seealso{ 53 | Useful links: 54 | \itemize{ 55 | \item \url{https://github.com/crsh/papaja} 56 | \item Report bugs at \url{https://github.com/crsh/papaja/issues} 57 | } 58 | 59 | } 60 | \author{ 61 | \strong{Maintainer}: Frederik Aust \email{frederik.aust@uni-koeln.de} (\href{https://orcid.org/0000-0003-4900-788X}{ORCID}) 62 | 63 | Authors: 64 | \itemize{ 65 | \item Marius Barth \email{marius.barth@uni-koeln.de} (\href{https://orcid.org/0000-0002-3421-6665}{ORCID}) 66 | } 67 | 68 | Other contributors: 69 | \itemize{ 70 | \item Birk Diedenhofen \email{mail@birkdiedenhofen.de} [contributor] 71 | \item Christoph Stahl \email{christoph.stahl@uni-koeln.de} [contributor] 72 | \item Joseph V. Casillas \email{joseph.casillas@rutgers.edu} [contributor] 73 | \item Rudolf Siegel \email{rudolf.siegel@uni-saarland.de} [contributor] 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /man/parse_bcp47.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{parse_bcp47} 4 | \alias{parse_bcp47} 5 | \title{Simple language names from BCP 47 tags} 6 | \usage{ 7 | parse_bcp47(x) 8 | } 9 | \arguments{ 10 | \item{x}{Character. BCP 47 tag.} 11 | } 12 | \value{ 13 | Character. Simple language name. 14 | } 15 | \description{ 16 | Internal function to translate BCP 47 tags to simple language names. 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/points.matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_plot.R 3 | \name{points.matrix} 4 | \alias{points.matrix} 5 | \title{Matrix Method for points()} 6 | \usage{ 7 | \method{points}{matrix}(x, y, type = "p", ...) 8 | } 9 | \description{ 10 | Internal function for convenient plotting of multiple points. 11 | \emph{This function is not exported.} 12 | } 13 | \keyword{internal} 14 | -------------------------------------------------------------------------------- /man/print_anova.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print_anova.R 3 | \name{print_anova} 4 | \alias{print_anova} 5 | \title{Format statistics from ANOVA (APA 6th edition)} 6 | \usage{ 7 | print_anova( 8 | x, 9 | intercept = FALSE, 10 | observed = NULL, 11 | es = "ges", 12 | mse = getOption("papaja.mse"), 13 | in_paren = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{Data.frame. A \code{data.frame} of class \code{apa_variance_table} as returned by \code{\link{arrange_anova}}.} 18 | 19 | \item{intercept}{Logical. Indicates if intercept test should be included in output.} 20 | 21 | \item{observed}{Character. The names of the factors that are observed, (i.e., not manipulated). Necessary for calculation of generalized eta-squared; otherwise ignored.} 22 | 23 | \item{es}{Character. The effect-size measure to be calculated; can be either \code{ges} for generalized eta-squared, \code{pes} for partial eta-squared or \code{es} for eta-squared. 24 | Note that eta-squared is calculated correctly if and only if the design is balanced.} 25 | 26 | \item{mse}{Logical. Indicates if mean squared errors should be included in output. Default is \code{TRUE}.} 27 | 28 | \item{in_paren}{Logical. Indicates if the formatted string will be reported inside parentheses. See details.} 29 | } 30 | \value{ 31 | A named list containing the following components: 32 | 33 | \describe{ 34 | \item{\code{statistic}}{A named list of character strings giving the test statistic, parameters, and \emph{p} 35 | value for each factor.} 36 | \item{\code{estimate}}{A named list of character strings giving the effect size estimates for each factor.} \% , either in units of the analyzed scale or as standardized effect size. 37 | \item{\code{full_result}}{A named list of character strings comprised of \code{estimate} and \code{statistic} for each factor.} 38 | \item{\code{table}}{A data.frame containing the complete ANOVA table, which can be passed to \code{\link{apa_table}}.} 39 | } 40 | } 41 | \description{ 42 | This function is the former internal workhorse of the \code{apa_print}-family for ANOVA. It takes a \code{data.frame} 43 | of class \code{apa_variance_table} and produces strings to report the results in accordance with APA manuscript 44 | guidelines. It is already deprecated and will soon be defunct. \emph{This function is not exported.} 45 | } 46 | \seealso{ 47 | \code{\link[=arrange_anova]{arrange_anova()}}, \code{\link[=apa_print.aov]{apa_print.aov()}} 48 | } 49 | \keyword{internal} 50 | -------------------------------------------------------------------------------- /man/print_model_comp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print_model_comp.R 3 | \name{print_model_comp} 4 | \alias{print_model_comp} 5 | \title{Typeset Statistical Results from Model Comparisons} 6 | \usage{ 7 | print_model_comp( 8 | x, 9 | models = NULL, 10 | conf.int = NULL, 11 | boot_samples = 1000, 12 | progress_bar = FALSE, 13 | in_paren = FALSE, 14 | observed = TRUE 15 | ) 16 | } 17 | \arguments{ 18 | \item{x}{A data frame of class \code{apa_variance_table} as returned by \code{\link[=arrange_anova]{arrange_anova()}}.} 19 | 20 | \item{models}{List. List containing fitted \code{lm} objects that were compared using \code{\link[=anova]{anova()}}. If the list is named, element names are used as model names in the output object.} 21 | 22 | \item{conf.int}{Numeric. Confidence level for the confidence interval for \eqn{\Delta R^2} if \code{x} is a model comparison object of class \code{anova}. If \code{conf.int = NULL} no confidence intervals are estimated.} 23 | 24 | \item{boot_samples}{Numeric. Number of bootstrap samples to estimate confidence intervals for \eqn{\Delta R^2} if \code{x} is a model comparison object of class \code{anova}; ignored if \code{conf.int = NULL}.} 25 | 26 | \item{progress_bar}{Logical. Determines whether a progress bar is printed while bootstrapping.} 27 | 28 | \item{in_paren}{Logical. Whether the formatted string is to be reported in 29 | parentheses. If \code{TRUE}, parentheses in the formatted string (e.g., those 30 | enclosing degrees of freedom) are replaced with brackets.} 31 | 32 | \item{observed}{Logical. Indicates whether predictor variables were 33 | observed. See details.} 34 | } 35 | \description{ 36 | This function is the workhorse of the \link[=apa_print.list]{apa_print()} method 37 | for model comparisons. It takes a data frame of class \code{apa_model_comp} and 38 | produces strings to report the results in accordance with APA manuscript 39 | guidelines. 40 | \emph{This function is not exported.} 41 | } 42 | \seealso{ 43 | \code{\link[=arrange_anova]{arrange_anova()}}, \code{\link[=apa_print.aov]{apa_print.aov()}} 44 | } 45 | \keyword{internal} 46 | -------------------------------------------------------------------------------- /man/print_scientific.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/apa_num.R 3 | \name{print_scientific} 4 | \alias{print_scientific} 5 | \title{Typeset scientific notation} 6 | \usage{ 7 | print_scientific(x) 8 | } 9 | \arguments{ 10 | \item{x}{Character.} 11 | } 12 | \description{ 13 | Typesets scientific notation of numbers into properly typeset math strings. 14 | } 15 | \keyword{internal} 16 | -------------------------------------------------------------------------------- /man/quote_from_tex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/revision_letter_format.R 3 | \name{quote_from_tex} 4 | \alias{quote_from_tex} 5 | \title{Quote from TeX document} 6 | \usage{ 7 | quote_from_tex( 8 | x, 9 | file = paste0(rmarkdown::metadata[["manuscript-tex"]], ".tex") 10 | ) 11 | } 12 | \arguments{ 13 | \item{x}{Character. One or more quote labels.} 14 | 15 | \item{file}{Character. Path to LaTeX file from which to quote.} 16 | } 17 | \value{ 18 | A character vector of LaTeX document text of class \code{knit_asis}, 19 | see \code{\link[knitr:asis_output]{knitr::asis_output()}}. 20 | } 21 | \description{ 22 | Includes a labelled quote from a LaTeX document 'asis'. 23 | } 24 | \details{ 25 | Searches the LaTeX document specified in \code{file} for labelled 26 | quotes, i.e. paragraphs that are enclosed in \verb{\% <@~\{#quote-label\}} and 27 | \verb{\% ~@>} tags in LaTeX comments on separate lines. The labelled quote is 28 | then inserted and rendered \code{asis}. To use labelled quote-tags in a 29 | \code{\link[=apa6_pdf]{apa6_pdf()}}-document, set the YAML front matter options 30 | \code{quote_labels: true}. 31 | } 32 | -------------------------------------------------------------------------------- /man/r_refs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/r_refs.R 3 | \name{r_refs} 4 | \alias{r_refs} 5 | \alias{create_bib} 6 | \title{Create a Reference File for R and R Packages} 7 | \usage{ 8 | r_refs( 9 | file, 10 | append = TRUE, 11 | prefix = "R-", 12 | type_pref = c("Article", "Book"), 13 | tweak = TRUE 14 | ) 15 | 16 | create_bib( 17 | x, 18 | file, 19 | append = TRUE, 20 | prefix = "R-", 21 | type_pref = c("Article", "Book"), 22 | tweak = TRUE 23 | ) 24 | } 25 | \arguments{ 26 | \item{file}{Character. Path and name of the file to be created or 27 | updated.} 28 | 29 | \item{append}{Logical. Indicates if existing bibliography should be 30 | complemented or overwritten. See details.} 31 | 32 | \item{prefix}{Character. Prefix for all R-package reference handles.} 33 | 34 | \item{type_pref}{Character. A vector of BibTeX entry types in the order by 35 | which to prioritize packages \code{CITATION} entries. See details.} 36 | 37 | \item{tweak}{Logical. Indicates whether to fix some known problems in 38 | citations (based on \code{\link[knitr]{write_bib}}).} 39 | 40 | \item{x}{Character. Names of packages to include in bibliography.} 41 | } 42 | \value{ 43 | Invisibly returns the bibliography written to \code{file}. 44 | } 45 | \description{ 46 | Creates a \code{.bib}-reference file for the installed R version and R-packages, 47 | so they can be cited in an R Markdown-document. 48 | } 49 | \details{ 50 | \code{r_refs} is a wrapper for \code{\link{create_bib}} to create a 51 | bibliography for R and all attached or cached packages. 52 | 53 | By default, if a file exists at the specified location, \code{r_refs} reads the 54 | file and appends missing citation information to the end of the file 55 | (\code{\link{create_bib}} always overwrites existing files). It is 56 | recommended to use a bibliography-file dedicated to R-references. 57 | 58 | \strong{Beware that chunks loading packages should generally \emph{not} be cached}. 59 | \code{r_refs} will make all packages loaded in cached chunks citable, but it 60 | won't know when you remove a package from a cached chunk. This can result 61 | in unused package references in your bibliography-file that will be cited 62 | when using \code{\link{cite_r}}. 63 | 64 | If a package provides citation information in a \code{CITATION} file, a 65 | reference is selected based on the preferred order of reference types 66 | specified in \code{type_pref}. By default, available articles are cited rather 67 | than books. If no reference of the specified types is available, the first 68 | reference is used. If multiple references of the preferred type are given 69 | all of them are cited. Finally, if no \code{CITATION} file exists a reference 70 | is generated from the \code{DESCRIPTION} file by \code{\link[utils]{citation}}. 71 | } 72 | \seealso{ 73 | \code{\link[=cite_r]{cite_r()}}, \code{\link[knitr:write_bib]{knitr::write_bib()}}, \code{\link[utils:citation]{utils::citation()}}, \code{\link[utils:toLatex]{utils::toLatex()}} 74 | } 75 | -------------------------------------------------------------------------------- /man/remove_comments.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/remove_comments.R 3 | \name{remove_comments} 4 | \alias{remove_comments} 5 | \title{Remove Comments} 6 | \usage{ 7 | remove_comments(x, file) 8 | } 9 | \arguments{ 10 | \item{x}{Character. Path to an R Markdown file.} 11 | 12 | \item{file}{Character. Name of the new R Markdown file without comments.} 13 | } 14 | \value{ 15 | No return value, called to write text to \code{file}. 16 | } 17 | \description{ 18 | Removes markdown comments from an R Markdown file. 19 | } 20 | -------------------------------------------------------------------------------- /man/render_appendix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_defunct.R 3 | \name{render_appendix} 4 | \alias{render_appendix} 5 | \title{Render Appendix (defunct)} 6 | \usage{ 7 | render_appendix( 8 | x, 9 | bibliography = rmarkdown::metadata$bibliography, 10 | csl = rmarkdown::metadata$csl, 11 | quiet = TRUE, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{x}{Character. Path to R Markdown file.} 17 | 18 | \item{bibliography}{Character. Paths to relevant bibliography file(s).} 19 | 20 | \item{csl}{Character. Path to CSL file to use. Defaults to APA-style.} 21 | 22 | \item{quiet}{Logical. Suppresses pandoc command line output; see \code{\link[rmarkdown]{render}}. 23 | If \code{FALSE} output will be included in the document.} 24 | 25 | \item{...}{ 26 | Arguments passed on to \code{\link[rmarkdown:pandoc_convert]{rmarkdown::pandoc_convert}} 27 | \describe{ 28 | \item{\code{input}}{Character vector containing paths to input files 29 | (files must be UTF-8 encoded)} 30 | \item{\code{to}}{Format to convert to (if not specified, you must specify 31 | \code{output})} 32 | \item{\code{from}}{Format to convert from (if not specified then the format is 33 | determined based on the file extension of \code{input}).} 34 | \item{\code{output}}{Output file (if not specified then determined based on format 35 | being converted to).} 36 | \item{\code{citeproc}}{\code{TRUE} to run the pandoc-citeproc filter (for processing 37 | citations) as part of the conversion.} 38 | \item{\code{options}}{Character vector of command line options to pass to pandoc.} 39 | \item{\code{verbose}}{\code{TRUE} to show the pandoc command line which was executed} 40 | \item{\code{wd}}{Working directory in which code will be executed. If not 41 | supplied, defaults to the common base directory of \code{input}.} 42 | }} 43 | } 44 | \value{ 45 | Returns \code{NULL} invisibly. 46 | } 47 | \description{ 48 | This function renders an R Markdown document \emph{without} YAML header to a TeX 49 | fragment inside an \code{appendix} environment, or to a markdown fragment (for 50 | Word output). \emph{This function has been defunct. Please use the appendix 51 | syntax provided by \pkg{bookdown} (see the \href{https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#special-headers}{bookdown manual}).} 52 | } 53 | \details{ 54 | \strong{This function is only exported for backwards compatibility.} 55 | It is now recommended \emph{not} to call \code{render_appendix()} directly. 56 | Instead, to add appendices to your manuscript, add the R Markdown file 57 | to the YAML front matter by using \code{appendix: "appendix.Rmd"}. 58 | 59 | Default chunk options and hooks are set to those used in the R Markdown 60 | document from which \code{render_appendix} is called; otherwise defaults of 61 | \code{\link[rmarkdown]{md_document}} are used. 62 | 63 | By default, \code{x} is converted to a TeX file, which can be included in an 64 | R Markdown document as \code{include}: 65 | 66 | \preformatted{ 67 | output: 68 | pdf_document: 69 | include: 70 | after_body: appendix.tex 71 | } 72 | 73 | If \code{render_appendix} is called form an R Markdown document with a 74 | target document type other than a PDF file, a markdown fragment is 75 | included. 76 | } 77 | \keyword{internal} 78 | -------------------------------------------------------------------------------- /man/revision_letter_pdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/revision_letter_format.R 3 | \name{revision_letter_pdf} 4 | \alias{revision_letter_pdf} 5 | \title{Revision Letter} 6 | \usage{ 7 | revision_letter_pdf(...) 8 | } 9 | \arguments{ 10 | \item{...}{Further arguments passed on to \code{\link[bookdown:html_document2]{bookdown::pdf_document2()}} and \code{\link[rmarkdown:pdf_document]{rmarkdown::pdf_document()}}.} 11 | } 12 | \value{ 13 | R Markdown output format to pass to \code{\link[rmarkdown:render]{rmarkdown::render()}}. 14 | } 15 | \description{ 16 | Template for creating a journal revision letters. 17 | } 18 | \details{ 19 | This document format is adapted from by the 20 | \href{https://github.com/mschroen/review_response_letter}{revision letter template} 21 | by Martin Schrön. 22 | 23 | It is possible to reference sections, figures, or tables in the revised 24 | manuscript, either by their number or by page. To do so, specify a path 25 | to the revised manuscript (omitting the file extension) in the YAML 26 | front matter (i.e., \code{manuscript-tex: file_name}) and ensure that 27 | you retain the \code{aux} file when rendering the revised manuscript. To do 28 | so, set the following option in a code chunk of the revised manuscript: 29 | \code{options(tinytex.clean = FALSE)}. To reference section, figure, or 30 | table numbers it is possible to use LaTeX (i.e., \verb{\\ref\{label\}}) or 31 | \pkg{bookdown} cross-referencing syntax (i.e., \verb{\\@ref(label)}). To 32 | reference the corresponding page numbers you must use the LaTeX syntax 33 | (i.e., \verb{\\pageref\{label\}}). 34 | 35 | To quote entire paragraphs directly from the revised manuscript see 36 | \code{\link[=quote_from_tex]{quote_from_tex()}}. 37 | } 38 | \seealso{ 39 | \code{\link[bookdown:html_document2]{bookdown::pdf_document2()}}], \code{\link[rmarkdown:pdf_document]{rmarkdown::pdf_document()}} 40 | } 41 | -------------------------------------------------------------------------------- /man/sanitize_terms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_text.R 3 | \name{sanitize_terms} 4 | \alias{sanitize_terms} 5 | \alias{sanitize_terms.character} 6 | \alias{sanitize_terms.factor} 7 | \alias{sanitize_terms.data.frame} 8 | \alias{sanitize_terms.list} 9 | \title{Sanitize Term Names} 10 | \usage{ 11 | sanitize_terms(x, standardized = FALSE) 12 | 13 | \method{sanitize_terms}{character}(x, standardized = FALSE) 14 | 15 | \method{sanitize_terms}{factor}(x, standardized = FALSE) 16 | 17 | \method{sanitize_terms}{data.frame}(x, standardized = FALSE) 18 | 19 | \method{sanitize_terms}{list}(x, standardized = FALSE) 20 | } 21 | \arguments{ 22 | \item{x}{Character. Vector of term names to be sanitized.} 23 | 24 | \item{standardized}{Logical. If \code{TRUE}, the name of the function [\code{\link[=scale]{scale()}}] will be 25 | removed from term names.} 26 | } 27 | \value{ 28 | An object of the same class as \code{x} containing sanitized term names as 29 | characters. 30 | } 31 | \description{ 32 | Remove characters from term names that will be difficult to address using the \code{$}-operator. 33 | \emph{This function is not exported.} 34 | } 35 | \examples{ 36 | sanitize_terms(c("(Intercept)", "Factor A", "Factor B", "Factor A:Factor B", "scale(FactorA)")) 37 | } 38 | -------------------------------------------------------------------------------- /man/se.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calculations.R 3 | \name{se} 4 | \alias{se} 5 | \title{Standard Error of the Mean} 6 | \usage{ 7 | se(x, na.rm = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{Numeric. A vector of observations.} 11 | 12 | \item{na.rm}{Logical. Specifies if missing values should be removed.} 13 | } 14 | \value{ 15 | The standard error of the mean as numeric vector of length 1. 16 | } 17 | \description{ 18 | Calculates the standard error of the mean. 19 | } 20 | -------------------------------------------------------------------------------- /man/sel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{sel} 4 | \alias{sel} 5 | \title{Select Parameters} 6 | \usage{ 7 | sel(x, i) 8 | } 9 | \arguments{ 10 | \item{x}{List. A list of parameter values.} 11 | 12 | \item{i}{Integer. The i-th element of each vector that is to be extracted.} 13 | } 14 | \description{ 15 | If a \code{list} holds vectors of parameter values, this function extracts the i-th parameter value from each vector and creates 16 | a new \code{list} with these values. Especially helpful if a function is called repeatedly via \code{do.call} with different 17 | parameter values from within a function. 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/simple_codebook.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variable_label.R 3 | \name{simple_codebook} 4 | \alias{simple_codebook} 5 | \title{Simple Codebook} 6 | \usage{ 7 | simple_codebook(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{data.frame. Data to be documented.} 11 | 12 | \item{...}{ 13 | Arguments passed on to \code{\link[utils:write.table]{utils::write.table}} 14 | \describe{ 15 | \item{\code{file}}{either a character string naming a file or a \link{connection} 16 | open for writing. \code{""} indicates output to the console.} 17 | \item{\code{append}}{logical. Only relevant if \code{file} is a character 18 | string. If \code{TRUE}, the output is appended to the 19 | file. If \code{FALSE}, any existing file of the name is destroyed.} 20 | \item{\code{quote}}{a logical value (\code{TRUE} or \code{FALSE}) or a 21 | numeric vector. If \code{TRUE}, any character or factor columns 22 | will be surrounded by double quotes. If a numeric vector, its 23 | elements are taken as the indices of columns to quote. In both 24 | cases, row and column names are quoted if they are written. If 25 | \code{FALSE}, nothing is quoted.} 26 | \item{\code{sep}}{the field separator string. Values within each row of 27 | \code{x} are separated by this string.} 28 | \item{\code{eol}}{the character(s) to print at the end of each line (row). 29 | For example, \code{eol = "\r\n"} will produce Windows' line endings on 30 | a Unix-alike OS, and \code{eol = "\r"} will produce files as expected by 31 | Excel:mac 2004.} 32 | \item{\code{na}}{the string to use for missing values in the data.} 33 | \item{\code{dec}}{the string to use for decimal points in numeric or complex 34 | columns: must be a single character.} 35 | \item{\code{row.names}}{either a logical value indicating whether the row 36 | names of \code{x} are to be written along with \code{x}, or a 37 | character vector of row names to be written.} 38 | \item{\code{col.names}}{either a logical value indicating whether the column 39 | names of \code{x} are to be written along with \code{x}, or a 40 | character vector of column names to be written. See the section on 41 | \sQuote{CSV files} for the meaning of \code{col.names = NA}.} 42 | \item{\code{qmethod}}{a character string specifying how to deal with embedded 43 | double quote characters when quoting strings. Must be one of 44 | \code{"escape"} (default for \code{write.table}), in which case the 45 | quote character is escaped in C style by a backslash, or 46 | \code{"double"} (default for \code{write.csv} and 47 | \code{write.csv2}), in which case it is doubled. You can specify 48 | just the initial letter.} 49 | \item{\code{fileEncoding}}{character string: if non-empty declares the 50 | encoding to be used on a file (not a connection) so the character data can 51 | be re-encoded as they are written. See \code{\link{file}}.} 52 | }} 53 | } 54 | \value{ 55 | Returns \code{NULL} invisibly. 56 | } 57 | \description{ 58 | Generate a simple codebook in CSV-format from a (labelled) \code{data.frame}. 59 | } 60 | \details{ 61 | If the \pkg{skimr} package is installed, an in-line histogram is 62 | added for all numeric variables. If columns are labelled, the labelles 63 | are included in the codebook. 64 | } 65 | \examples{ 66 | variable_labels(cars) <- c(speed = "Speed [ft/s]", dist = "Distance traveled [m]") 67 | simple_codebook(cars, file = file.path(tempdir(), "cars_codebook.csv")) 68 | } 69 | \seealso{ 70 | \code{\link[utils:write.table]{utils::write.csv()}} 71 | } 72 | -------------------------------------------------------------------------------- /man/sort_columns.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{sort_columns} 4 | \alias{sort_columns} 5 | \title{Sort the Columns of an APA Results Table} 6 | \usage{ 7 | sort_columns(x) 8 | } 9 | \arguments{ 10 | \item{x}{A \code{data.frame} with standardized column names.} 11 | } 12 | \description{ 13 | An internal function that sorts the columns of a \code{data.frame} according to 14 | our standards. 15 | } 16 | \keyword{internal} 17 | -------------------------------------------------------------------------------- /man/sort_terms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{sort_terms} 4 | \alias{sort_terms} 5 | \title{Sort ANOVA or Regression Table by Predictors/Effects} 6 | \usage{ 7 | sort_terms(x, colname) 8 | } 9 | \arguments{ 10 | \item{x}{A data frame. For example, the table element produced by \code{\link[=apa_print]{apa_print()}}.} 11 | 12 | \item{colname}{Character. Column name of the \code{data.frame} containing the terms to sort.} 13 | } 14 | \value{ 15 | Returns the same \code{data.frame} with reordered rows. 16 | } 17 | \description{ 18 | Sort rows in ANOVA or regression tables produced by \code{\link[=apa_print]{apa_print()}} 19 | by complexity (i.e., main effects, two-way interactions, three-way interactions, etc.). 20 | } 21 | \examples{ 22 | ## From Venables and Ripley (2002) p. 165. 23 | npk_aov <- aov(yield ~ block + N * P * K, npk) 24 | npk_aov_results <- apa_print(npk_aov) 25 | sort_terms(npk_aov_results$table, "term") 26 | } 27 | -------------------------------------------------------------------------------- /man/strip_math_tags.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils_text.R 3 | \name{svl} 4 | \alias{svl} 5 | \alias{strip_math_tags} 6 | \title{Strip Math Tags from Variable Labels or Strings} 7 | \usage{ 8 | svl(x, use_math = FALSE) 9 | 10 | strip_math_tags(x) 11 | } 12 | \arguments{ 13 | \item{x}{A (labelled) character string.} 14 | } 15 | \description{ 16 | Internal function to strip math tags from variable labels or strings. \code{svl()} 17 | returns the stripped variable label of \code{x}, if available. \code{strip_math_tags} returns 18 | the stripped character \code{x}. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/summary.papaja_wsci.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calculations.R 3 | \name{summary.papaja_wsci} 4 | \alias{summary.papaja_wsci} 5 | \title{Summarize Within-Subjects Confidence Intervals} 6 | \usage{ 7 | \method{summary}{papaja_wsci}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{papaja_wsci}, generated with function \code{\link[=wsci]{wsci()}}.} 11 | 12 | \item{...}{Further arguments that may be passed, currently ignored.} 13 | } 14 | \value{ 15 | A \code{data.frame} containing means as well as lower and upper confidence 16 | bounds for each cell of the design. 17 | } 18 | \description{ 19 | Calculate upper and lower limits of within-subjects confidence intervals calculated 20 | with \code{\link[=wsci]{wsci()}} and return them along their respective means. 21 | } 22 | -------------------------------------------------------------------------------- /man/theme_apa.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/theme_apa.R 3 | \name{theme_apa} 4 | \alias{theme_apa} 5 | \title{APA-style \code{ggplot2} Theme} 6 | \usage{ 7 | theme_apa(base_size = 12, base_family = "", box = FALSE) 8 | } 9 | \arguments{ 10 | \item{base_size}{Numeric. Base font size; other font sizes and margins are 11 | adjusted relative to this.} 12 | 13 | \item{base_family}{Character. Base font family.} 14 | 15 | \item{box}{Logical. Indicates whether to draw a black panel border.} 16 | } 17 | \value{ 18 | Object of class \code{theme} and \code{gg}, see \code{\link[ggplot2:theme]{ggplot2::theme()}}. 19 | } 20 | \description{ 21 | \pkg{ggplot2} theme with a white panel background, no grid lines, large axis 22 | and legend titles, and increased text padding for better readability. 23 | } 24 | \examples{ 25 | \donttest{ 26 | # Copied from ?ggtheme 27 | mtcars2 <- within(mtcars, { 28 | vs <- factor(vs, labels = c("V-shaped", "Straight")) 29 | am <- factor(am, labels = c("Automatic", "Manual")) 30 | cyl <- factor(cyl) 31 | gear <- factor(gear) 32 | }) 33 | 34 | library("ggplot2") 35 | p1 <- ggplot(mtcars2) + 36 | geom_point(aes(x = wt, y = mpg, colour = gear)) + 37 | labs( 38 | title = "Fuel economy declines as weight increases", 39 | subtitle = "(1973-1974)", 40 | x = "Weight (1000 lbs)", 41 | y = "Fuel economy (mpg)", 42 | colour = "Gears" 43 | ) 44 | 45 | p1 46 | p1 + theme_apa() 47 | } 48 | } 49 | \seealso{ 50 | \code{\link[ggplot2:ggtheme]{ggplot2::theme_bw()}}, \code{\link[ggplot2:theme]{ggplot2::theme()}} 51 | } 52 | -------------------------------------------------------------------------------- /man/transmute_df_into_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/transmute_df_into_label.R 3 | \name{transmute_df_into_label} 4 | \alias{transmute_df_into_label} 5 | \alias{df_into_label} 6 | \alias{transmute_df_into_label.apa_results} 7 | \alias{transmute_df_into_label.apa_results_table} 8 | \title{Transmute Degrees-of-Freedom Columns into Variable Labels} 9 | \usage{ 10 | transmute_df_into_label(x, check_df = TRUE, ...) 11 | 12 | df_into_label(x, check_df = TRUE, ...) 13 | 14 | \method{transmute_df_into_label}{apa_results}(x, check_df = TRUE, ...) 15 | 16 | \method{transmute_df_into_label}{apa_results_table}(x, check_df = TRUE, ...) 17 | } 18 | \arguments{ 19 | \item{x}{Either the complete output object created by \code{\link[=apa_print]{apa_print()}} methods, 20 | or the \code{table} component of such objects.} 21 | 22 | \item{check_df}{Logical. If TRUE (the default), checks if degrees-of-freedom-columns contain non-integer values.} 23 | 24 | \item{...}{further arguments passed from an to other methods} 25 | } 26 | \value{ 27 | An object of the same class as \code{x}, where a redundant column with 28 | degrees of freedom has been incorporated into the column label of the column 29 | \code{statistic}. 30 | } 31 | \description{ 32 | Takes the output from \code{\link[=apa_print]{apa_print()}} methods and modifies the results table 33 | by transmuting information about degrees of freedom into the variable labels of 34 | test-statistic columns. 35 | } 36 | \examples{ 37 | apa_out <- apa_print(aov(yield ~ N * P, npk)) 38 | 39 | # Standard output with separate columns for degrees of freedom: 40 | apa_out$table 41 | 42 | # Modified output where degrees of freedom are incorporated into the variable 43 | # label of column 'statistic': 44 | transmute_df_into_label(apa_out)$table 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /man/validate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{validate} 4 | \alias{validate} 5 | \title{Validate Function Input} 6 | \usage{ 7 | validate( 8 | x, 9 | name = NULL, 10 | check_class = NULL, 11 | check_mode = NULL, 12 | check_integer = FALSE, 13 | check_NA = TRUE, 14 | check_infinite = TRUE, 15 | check_length = NULL, 16 | check_dim = NULL, 17 | check_range = NULL, 18 | check_cols = NULL 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{Function input.} 23 | 24 | \item{name}{Character. Name of variable to validate; if \code{NULL} variable name of object supplied to \code{x} is used.} 25 | 26 | \item{check_class}{Character. Name of class to expect.} 27 | 28 | \item{check_mode}{Character. Name of mode to expect.} 29 | 30 | \item{check_integer}{Logical. If \code{TRUE} an object of type \code{integer} or a whole number \code{numeric} is expected.} 31 | 32 | \item{check_NA}{Logical. If \code{TRUE} an non-\code{NA} object is expected.} 33 | 34 | \item{check_infinite}{Logical. If \code{TRUE} a finite object is expected.} 35 | 36 | \item{check_length}{Integer. Length of the object to expect.} 37 | 38 | \item{check_dim}{Numeric. Vector of object dimensions to expect.} 39 | 40 | \item{check_range}{Numeric. Vector of length 2 defining the expected range of the object.} 41 | 42 | \item{check_cols}{Character. Vector of columns that are intended to be in a \code{data.frame}.} 43 | } 44 | \description{ 45 | This function can be used to validate the input to functions. 46 | \emph{This function is not exported.} 47 | } 48 | \keyword{internal} 49 | -------------------------------------------------------------------------------- /man/word_title_page.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/word_title_page.R 3 | \name{word_title_page} 4 | \alias{word_title_page} 5 | \title{Create title page} 6 | \usage{ 7 | word_title_page(x) 8 | } 9 | \arguments{ 10 | \item{x}{List. Meta data of the document as a result from \code{\link[yaml]{yaml.load}}.} 11 | } 12 | \description{ 13 | Creates text for the title and abstract page for MS Word documents. 14 | \emph{This function is not exported.} 15 | } 16 | \seealso{ 17 | \code{\link[=apa6_docx]{apa6_docx()}} 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/wsci.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calculations.R 3 | \name{wsci} 4 | \alias{wsci} 5 | \alias{within_subjects_conf_int} 6 | \title{Within-Subjects Confidence Intervals} 7 | \usage{ 8 | wsci(data, id, factors, dv, level = 0.95, method = "Morey") 9 | 10 | within_subjects_conf_int(data, id, factors, dv, level = 0.95, method = "Morey") 11 | } 12 | \arguments{ 13 | \item{data}{A \code{data.frame} that contains the data.} 14 | 15 | \item{id}{Character. Variable name that identifies subjects.} 16 | 17 | \item{factors}{Character. A vector of variable names that is used to stratify the data.} 18 | 19 | \item{dv}{Character. The name of the dependent variable.} 20 | 21 | \item{level}{Numeric. Defines the width of the interval. Defaults to 0.95 22 | for 95\% confidence intervals.} 23 | 24 | \item{method}{Character. The method that is used to calculate CIs. Currently, 25 | "Morey" and "Cousineau" are supported. Defaults to "Morey".} 26 | } 27 | \value{ 28 | A \code{data.frame} with additional class \code{papaja_wsci}. 29 | The \code{summary()} method for this class returns a \code{data.frame} with 30 | means along lower and upper limit for each cell of the design. 31 | } 32 | \description{ 33 | Calculate Cousineau-Morey within-subjects confidence intervals. 34 | } 35 | \examples{ 36 | wsci( 37 | data = npk 38 | , id = "block" 39 | , dv = "yield" 40 | , factors = c("N", "P") 41 | ) 42 | } 43 | \references{ 44 | Morey, R. D. (2008). Confidence Intervals from Normalized Data: A correction to Cousineau (2005). 45 | \emph{Tutorials in Quantitative Methods for Psychology}, \emph{4}(2), 61--64. 46 | 47 | Cousineau, D. (2005). Confidence intervals in within-subjects designs: 48 | A simpler solution to Loftus and Masson's method. 49 | \emph{Tutorials in Quantitative Methods for Psychology}, \emph{1}(1), 42--45. 50 | } 51 | -------------------------------------------------------------------------------- /papaja.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageBuildArgs: --compact-vignettes=both 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /tests/spelling.R: -------------------------------------------------------------------------------- 1 | if(requireNamespace('spelling', quietly = TRUE)) 2 | spelling::spell_check_test(vignettes = TRUE, error = FALSE, 3 | skip_on_cran = TRUE) 4 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library("testthat") 2 | library("papaja") 3 | 4 | test_check("papaja") 5 | -------------------------------------------------------------------------------- /tests/testthat/data/lm_fit_output1.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/lm_fit_output1.Rdata -------------------------------------------------------------------------------- /tests/testthat/data/lm_fit_output2.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/lm_fit_output2.Rdata -------------------------------------------------------------------------------- /tests/testthat/data/lm_fit_output3.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/lm_fit_output3.Rdata -------------------------------------------------------------------------------- /tests/testthat/data/lm_fit_output4.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/lm_fit_output4.Rdata -------------------------------------------------------------------------------- /tests/testthat/data/lm_fit_output5.Rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/lm_fit_output5.Rdata -------------------------------------------------------------------------------- /tests/testthat/data/mixed_data.rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/mixed_data.rdata -------------------------------------------------------------------------------- /tests/testthat/data/ow_data.rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/ow_data.rdata -------------------------------------------------------------------------------- /tests/testthat/data/rm_data.rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/rm_data.rdata -------------------------------------------------------------------------------- /tests/testthat/data/tw_data.rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/tw_data.rdata -------------------------------------------------------------------------------- /tests/testthat/data/tw_rm_data.rdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tests/testthat/data/tw_rm_data.rdata -------------------------------------------------------------------------------- /tests/testthat/test_apa6_formats.R: -------------------------------------------------------------------------------- 1 | 2 | test_that( 3 | "apa6_pdf() defaults" 4 | , { 5 | apa6_format <- apa6_pdf() 6 | 7 | expect_s3_class(apa6_format, "rmarkdown_output_format", exact = TRUE) 8 | expect_identical(apa6_format$knitr$opts_chunk$echo, FALSE) 9 | expect_identical(apa6_format$knitr$opts_chunk$message, FALSE) 10 | expect_identical(apa6_format$knitr$opts_chunk$fig.cap, " ") 11 | expect_identical(apa6_format$knitr$opts_knit$rmarkdown.pandoc.to, "latex") 12 | expect_identical(apa6_format$knitr$opts_chunk$dev, c("pdf", "png")) 13 | expect_identical(apa6_format$knitr$opts_chunk$dpi, 300) 14 | } 15 | ) 16 | 17 | test_that( 18 | "apa6_docx() defaults" 19 | , { 20 | apa6_format <- apa6_docx() 21 | 22 | expect_s3_class(apa6_format, "rmarkdown_output_format", exact = TRUE) 23 | expect_identical( 24 | apa6_format$knitr$opts_chunk 25 | , expected = list( 26 | dev = c("png", "pdf") 27 | , dpi = 300 28 | , fig.width = 5 29 | , fig.height = 4 30 | , echo = FALSE 31 | , message = FALSE 32 | ) 33 | ) 34 | } 35 | ) 36 | -------------------------------------------------------------------------------- /tests/testthat/test_apa_print.R: -------------------------------------------------------------------------------- 1 | context("apa_print()") 2 | 3 | test_that( 4 | "Default method" 5 | , { 6 | unknown_object <- list() 7 | class(unknown_object) <- "foobar" 8 | expect_error(apa_print(unknown_object), regexp = "github.com/crsh/papaja/issues ") 9 | } 10 | ) 11 | -------------------------------------------------------------------------------- /tests/testthat/test_apa_print_glht.R: -------------------------------------------------------------------------------- 1 | 2 | context("apa_print() for multcomp") 3 | 4 | test_that( 5 | "glht() for multiple linear model" 6 | , { 7 | skip("Structure of glht output not decided, yet.") 8 | ### from the examples section 9 | lmod <- lm(Fertility ~ ., data = swiss) 10 | ### define coefficients of linear function directly 11 | K <- diag(length(stats::coef(lmod)))[-1,] 12 | rownames(K) <- names(stats::coef(lmod))[-1] 13 | K 14 | ### set up general linear hypothesis 15 | comparisons <- multcomp::glht(lmod, linfct = K) 16 | 17 | apa_comp <- apa_print(comparisons) 18 | expect_apa_results( 19 | apa_comp 20 | , labels = list( 21 | term = "Term" 22 | , estimate = "$\\Delta M$" 23 | , conf.int = "95\\% CI" 24 | , statistic = "$t$" 25 | , df = "$\\mathit{df}$" 26 | , p.value = "$p$" 27 | ) 28 | ) 29 | 30 | } 31 | ) 32 | 33 | test_that( 34 | "glht() for multiple comparisons procedure" 35 | , { 36 | skip("Structure of glht output not decided, yet.") 37 | amod <- aov(breaks ~ tension, data = warpbreaks) 38 | 39 | ### set up all-pair comparisons for factor `tension' 40 | ### using a symbolic description (`type' argument 41 | ### to `contrMat()') 42 | comparisons <- multcomp::glht(amod, linfct = multcomp::mcp(tension = "Tukey")) 43 | apa_comp2 <- apa_print(summary(comparisons)) 44 | expect_apa_results( 45 | apa_comp2 46 | , labels = list( 47 | term = "Term" 48 | , estimate = "$\\Delta M$" 49 | , conf.int = "95\\% CI" 50 | , statistic = "$t(51)$" 51 | , p.value = "$p_{adj}$" 52 | ) 53 | ) 54 | } 55 | ) 56 | 57 | test_that( 58 | "Deprecated 'ci' argument" 59 | , { 60 | amod <- aov(breaks ~ tension, data = warpbreaks) 61 | comparisons <- multcomp::glht(amod, linfct = multcomp::mcp(tension = "Tukey")) 62 | 63 | expect_warning( 64 | apa_print(comparisons, ci = .99) 65 | , regexp = "Using argument 'ci' in calls to 'apa_print()' is deprecated. Please use 'conf.int' instead." 66 | , fixed = TRUE 67 | ) 68 | } 69 | ) 70 | -------------------------------------------------------------------------------- /tests/testthat/test_apa_print_manova.R: -------------------------------------------------------------------------------- 1 | 2 | context("apa_print() for MANOVA") 3 | 4 | test_that( 5 | "Two-way MANOVA: apa_print.manova and apa_print.summary.manova" 6 | , { 7 | set.seed(42) 8 | 9 | data <- npk 10 | data$yield2 <- as.integer(data$N) * 2 + rnorm(n = nrow(data), sd = 2) 11 | 12 | x1 <- manova(formula = cbind(yield, yield2) ~ N * P, data = data) 13 | x2 <- summary(x1, test = "Wilks") 14 | 15 | manova1 <- apa_print(x1) # Pillai 16 | manova2 <- apa_print(x2) # Wilks 17 | manova3 <- apa_print(x1, test = "H") # Hotelling-Lawley, pmatch 18 | manova4 <- apa_print(x1, test = "R", in_paren = TRUE) # Roy's root, pmatch 19 | 20 | expect_apa_results( 21 | manova1 22 | , labels = list( 23 | term = "Effect" 24 | , multivariate.statistic = "$V$" 25 | , statistic = "$F$" 26 | , df = "$\\mathit{df}$" 27 | , df.residual = "$\\mathit{df}_{\\mathrm{res}}$" 28 | , p.value = "$p$" 29 | ) 30 | ) 31 | expect_apa_results( 32 | manova2 33 | , labels = list( 34 | term = "Effect" 35 | , multivariate.statistic = "$\\Lambda$" 36 | , statistic = "$F$" 37 | , df = "$\\mathit{df}$" 38 | , df.residual = "$\\mathit{df}_{\\mathrm{res}}$" 39 | , p.value = "$p$" 40 | ) 41 | ) 42 | expect_apa_results( 43 | manova3 44 | , labels = list( 45 | term = "Effect" 46 | , multivariate.statistic = "$T$" 47 | , statistic = "$F$" 48 | , df = "$\\mathit{df}$" 49 | , df.residual = "$\\mathit{df}_{\\mathrm{res}}$" 50 | , p.value = "$p$" 51 | ) 52 | ) 53 | expect_apa_results( 54 | manova4 55 | , labels = list( 56 | term = "Effect" 57 | , multivariate.statistic = "$\\theta$" 58 | , statistic = "$F$" 59 | , df = "$\\mathit{df}$" 60 | , df.residual = "$\\mathit{df}_{\\mathrm{res}}$" 61 | , p.value = "$p$" 62 | ) 63 | ) 64 | 65 | expect_identical( 66 | object = manova1$table$term 67 | , expected = structure( 68 | c("N", "P", "N $\\times$ P") 69 | , label = "Effect" 70 | , class = c("tiny_labelled", "character") 71 | ) 72 | ) 73 | 74 | expect_identical( 75 | object = manova1$statistic$N 76 | , expected = "$V = 0.25$, $F(2, 19) = 3.22$, $p = .062$" 77 | ) 78 | expect_identical( 79 | object = manova2$full_result$N_P 80 | , expected = "$\\Lambda = 0.96$, $F(2, 19) = 0.37$, $p = .697$" 81 | ) 82 | expect_identical( 83 | object = manova3$full_result$P 84 | , expected = "$T = 0.02$, $F(2, 19) = 0.20$, $p = .821$" 85 | ) 86 | # in_paren 87 | expect_identical( 88 | object = manova4$statistic$N 89 | , expected = "$\\theta = 0.34$, $F[2, 19] = 3.22$, $p = .062$" 90 | ) 91 | } 92 | ) 93 | 94 | test_that( 95 | "Anova.mlm from MANOVA not supported" 96 | , { 97 | set.seed(42) 98 | 99 | data <- npk 100 | data$yield2 <- as.integer(data$N) * 2 + rnorm(n = nrow(data), sd = 2) 101 | 102 | expect_error( 103 | apa_print(car::Manova(manova(formula = cbind(yield, yield2) ~ N * P, data = data), type = 3)) 104 | , fixed = TRUE 105 | , regexp = "Anova.mlm objects from car::Manova are not supported, yet. Visit https://github.com/crsh/papaja/issues to request support for this class. You can try using stats::manova instead if Type I oder Type II sums of squares are adequate for your analysis." 106 | ) 107 | } 108 | ) 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /tests/testthat/test_apa_print_nlme.R: -------------------------------------------------------------------------------- 1 | 2 | test_that( 3 | "apa_print.lme() and apa_print.anova.lme()" 4 | , { 5 | # From the examples section: 6 | fm1 <- nlme::lme(distance ~ age, data = nlme::Orthodont, method = "ML") # random is ~ age 7 | fm2 <- nlme::lme(distance ~ age + Sex, data = nlme::Orthodont, random = ~ 1, method = "ML") 8 | 9 | single_anova <- anova(fm1) 10 | model_comp <- anova(fm1, fm2) 11 | 12 | lme_model <- apa_print(fm1) 13 | lme_anova <- apa_print(single_anova) 14 | 15 | expect_apa_results( 16 | lme_model 17 | , labels = list( 18 | term = "Term" 19 | , estimate = "$\\hat{\\beta}$" 20 | , conf.int = "95\\% CI" 21 | , statistic = "$t$" 22 | , df = "$\\mathit{df}$" 23 | , p.value = "$p$" 24 | ) 25 | ) 26 | expect_identical( 27 | lme_model$full_result 28 | , expected = list( 29 | Intercept = "$\\hat{\\beta} = 16.76$, 95\\% CI $[15.25, 18.28]$, $t(80) = 21.83$, $p < .001$" 30 | , age = "$\\hat{\\beta} = 0.66$, 95\\% CI $[0.52, 0.80]$, $t(80) = 9.35$, $p < .001$" 31 | ) 32 | ) 33 | 34 | expect_error( 35 | apa_print(model_comp) 36 | , "Model-comparison tables of class 'anova.lme' are not supported." 37 | ) 38 | 39 | # Also works for nonlinear models of class 'c("nlme", "lme")' 40 | # from the example section of nlme::nlme() 41 | fm1 <- nlme::nlme(height ~ stats::SSasymp(age, Asym, R0, lrc), 42 | data = datasets::Loblolly, 43 | fixed = Asym + R0 + lrc ~ 1, 44 | random = Asym ~ 1, 45 | start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) 46 | nlme_model <- apa_print(fm1) 47 | 48 | expect_apa_results( 49 | nlme_model 50 | , labels = list( 51 | term = "Term" 52 | , estimate = "$\\hat{\\beta}$" 53 | , conf.int = "95\\% CI" 54 | , statistic = "$t$" 55 | , df = "$\\mathit{df}$" 56 | , p.value = "$p$" 57 | ) 58 | ) 59 | expect_identical( 60 | object = nlme_model$full_result 61 | , expected = list( 62 | Asym = "$\\hat{\\beta} = 101.45$, 95\\% CI $[96.63, 106.27]$, $t(68) = 41.21$, $p < .001$" 63 | , R0 = "$\\hat{\\beta} = -8.63$, 95\\% CI $[-9.25, -8.00]$, $t(68) = -27.13$, $p < .001$" 64 | , lrc = "$\\hat{\\beta} = -3.23$, 95\\% CI $[-3.30, -3.17]$, $t(68) = -94.36$, $p < .001$" 65 | ) 66 | ) 67 | 68 | expect_warning( 69 | apa_print(fm1, args_confint = .9) 70 | , "deprecated. Please use 'conf.int' instead." 71 | ) 72 | } 73 | ) 74 | 75 | test_that( 76 | "Deprecated 'args_confint' argument" 77 | , { 78 | fm1 <- nlme::nlme(height ~ stats::SSasymp(age, Asym, R0, lrc), 79 | data = datasets::Loblolly, 80 | fixed = Asym + R0 + lrc ~ 1, 81 | random = Asym ~ 1, 82 | start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) 83 | expect_warning( 84 | nlme_model <- apa_print(fm1, args = .6) 85 | , regexp = "Using argument 'args_confint' in calls to 'apa_print()' is deprecated. Please use 'conf.int' instead." 86 | , fixed = TRUE 87 | ) 88 | expect_identical( 89 | nlme_model$estimate$Asym 90 | , "$\\hat{\\beta} = 101.45$, 60\\% CI $[99.40, 103.50]$" 91 | ) 92 | 93 | 94 | } 95 | ) 96 | -------------------------------------------------------------------------------- /tests/testthat/test_apa_print_wsci.R: -------------------------------------------------------------------------------- 1 | test_that( 2 | "apa_print() for within-subjects CIs" 3 | , { 4 | data <- npk 5 | variable_labels(data) <- c(N = "Nitrogen $N$") 6 | wsci_out <- wsci(data = data, id = "block", dv = "yield", factors = c("N", "P"), level = .98) 7 | 8 | apa_wsci <- apa_print(wsci_out, digits = 3L) 9 | 10 | # some expectations 11 | expect_apa_results( 12 | apa_wsci 13 | , labels = list( 14 | N = "Nitrogen $N$" 15 | , P = "P" 16 | , estimate = "$M$" 17 | , conf.int = "98\\% CI" 18 | ) 19 | ) 20 | expect_identical( 21 | names(apa_wsci$estimate) 22 | , c("N0_P0", "N0_P1", "N1_P0", "N1_P1") 23 | ) 24 | expect_identical( 25 | apa_wsci$estimate$N0_P0 26 | , "$M = 51.717$, 98\\% CI $[46.603, 56.831]$" 27 | ) 28 | } 29 | ) 30 | -------------------------------------------------------------------------------- /tests/testthat/test_apa_table.R: -------------------------------------------------------------------------------- 1 | context("apa_table()") 2 | 3 | test_that( 4 | "" 5 | , { 6 | load("data/mixed_data.rdata") 7 | 8 | descriptives <- dplyr::group_by(mixed_data, Dosage) 9 | 10 | descriptives <- dplyr::summarize( 11 | descriptives 12 | , Mean = apa_num( mean(Recall) ) 13 | , Median = apa_num( median(Recall) ) 14 | , SD = apa_num( sd(Recall) ) 15 | , Min = apa_num( min(Recall) ) 16 | , Max = apa_num( max(Recall) ) 17 | ) 18 | 19 | skip_on_cran() 20 | rmarkdown::render( 21 | "test_apa_table.Rmd" 22 | , output_dir = tempdir() 23 | , quiet = TRUE 24 | ) 25 | } 26 | ) 27 | 28 | test_that( 29 | "Check that midrules are added even if col.names = NULL" 30 | , { 31 | my_table <- t(apply(cars, 2, function(x) # Create data 32 | round(c(Mean = mean(x), SD = sd(x), Min = min(x), Max = max(x)), 2) 33 | )) 34 | 35 | res_table <- apa_table(my_table, midrules = c(1), caption = "should have midrules", col.names = NULL) 36 | table_lines <- unlist(strsplit(res_table, split = "\n", fixed = TRUE)) 37 | 38 | expect_identical( 39 | table_lines[[13L]] 40 | , expected = "speed & 15.40 & 5.29 & 4.00 & 25.00\\\\ \\midrule" 41 | ) 42 | 43 | } 44 | ) 45 | -------------------------------------------------------------------------------- /tests/testthat/test_lookup_tables.R: -------------------------------------------------------------------------------- 1 | 2 | test_that( 3 | "Check lookup tables" 4 | , { 5 | expect( 6 | !any(duplicated(names(lookup_names))) 7 | , "Some names are duplicated in 'lookup_names'." 8 | ) 9 | expect( 10 | !any(duplicated(names(lookup_labels))) 11 | , "Some names are duplicated in 'lookup_labels'." 12 | ) 13 | } 14 | ) 15 | -------------------------------------------------------------------------------- /tests/testthat/test_meta.R: -------------------------------------------------------------------------------- 1 | context("localize()") 2 | 3 | test_that( 4 | "Localize document" 5 | , { 6 | lang <- papaja:::localize("english") 7 | 8 | expect_is(lang, "list") 9 | expect_equal(length(lang), 14) 10 | expect_equal(names(lang), c("author_note", "abstract", "keywords", "word_count", "table", "figure", "note", "correspondence", "email", "version", "and", "cite_r_packages_s", "cite_r_packages_pl", "cite_r_footnote")) 11 | expect_equivalent(sapply(lang, class), rep("character", 14)) 12 | } 13 | ) 14 | -------------------------------------------------------------------------------- /tests/testthat/test_print_anova.R: -------------------------------------------------------------------------------- 1 | context("print_anova()") 2 | 3 | test_that( 4 | "Calculation of eta-squared" 5 | , { 6 | npk$id <- 1:nrow(npk) 7 | ow_aov1 <- expect_warning(apa_print(aov(yield ~ N, npk), es = c("ges", "pes", "es"))) 8 | ow_aov2 <- expect_warning(apa_print(aov(yield ~ N, npk), es = c("pes", "es"))) 9 | ow_aov3 <- apa_print(aov(yield ~ N, npk), es = c("es")) 10 | expect_equal(ow_aov1$estimate$N, "$\\hat{\\eta}^2_G = .216$") 11 | expect_equal(ow_aov2$estimate$N, "$\\hat{\\eta}^2_p = .216$") 12 | expect_equal(ow_aov3$estimate$N, "$\\hat{\\eta}^2 = .216$") 13 | tw_aov1 <- apa_print(aov(yield ~ N * P, npk), es = c("ges"), observed = "N") 14 | tw_aov2 <- apa_print(aov(yield ~ N * P, npk), es = c("pes"), observed = "N") 15 | tw_aov3 <- apa_print(aov(yield ~ N * P, npk), es = c("es"), observed = "N") 16 | expect_equal(tw_aov1$estimate$N, "$\\hat{\\eta}^2_G = .218$") 17 | expect_equal(tw_aov1$estimate$P, "$\\hat{\\eta}^2_G = .010$") 18 | expect_equal(tw_aov1$estimate$N_P, "$\\hat{\\eta}^2_G = .025$") 19 | 20 | expect_equal(tw_aov2$estimate$N, "$\\hat{\\eta}^2_p = .224$") 21 | expect_equal(tw_aov2$estimate$P, "$\\hat{\\eta}^2_p = .013$") 22 | expect_equal(tw_aov2$estimate$N_P, "$\\hat{\\eta}^2_p = .031$") 23 | 24 | expect_equal(tw_aov3$estimate$N, "$\\hat{\\eta}^2 = .216$") 25 | expect_equal(tw_aov3$estimate$P, "$\\hat{\\eta}^2 = .010$") 26 | expect_equal(tw_aov3$estimate$N_P, "$\\hat{\\eta}^2 = .024$") 27 | 28 | tw_aov_afex <- expect_warning( 29 | apa_print(afex::aov_ez(id = "id", dv = "yield", between = c("N", "P"), data = npk), es = c("ges", "pes", "es"), observed = "N") 30 | ) 31 | expect_identical(tw_aov1$table, tw_aov_afex$table) 32 | } 33 | ) 34 | 35 | test_that( 36 | "print_anova(): Throw an error if a missing variable is specified as `observed`." 37 | , { 38 | expect_error( 39 | apa_print(aov(formula = yield ~ N, data = npk), observed = "P") 40 | , "Observed variable not in data: P" 41 | ) 42 | } 43 | ) 44 | -------------------------------------------------------------------------------- /tests/testthat/test_skeleton.R: -------------------------------------------------------------------------------- 1 | test_that( 2 | "Knit bare skeleton" 3 | , { 4 | skip_on_cran() 5 | 6 | # Render skeleton 7 | bare_path <- file.path(tempdir(), "bare_skeleton.Rmd") 8 | 9 | rmarkdown::draft( 10 | bare_path 11 | , system.file( 12 | "rmarkdown", "templates", "apa6" 13 | , package = "papaja" 14 | ) 15 | , create_dir = FALSE 16 | , edit = FALSE 17 | ) 18 | 19 | try( 20 | rmarkdown::render( 21 | bare_path 22 | , output_format = "papaja::apa6_pdf" 23 | , quiet = TRUE 24 | ) 25 | ) 26 | expect_true(file.exists(gsub("\\.Rmd", ".pdf", bare_path))) 27 | 28 | try( 29 | rmarkdown::render( 30 | file.path(tempdir(), "bare_skeleton.Rmd") 31 | , output_format = "papaja::apa6_docx" 32 | , quiet = TRUE 33 | ) 34 | ) 35 | expect_true(file.exists(gsub("\\.Rmd", ".docx", bare_path))) 36 | } 37 | ) 38 | -------------------------------------------------------------------------------- /tests/testthat/test_theme_apa.R: -------------------------------------------------------------------------------- 1 | test_that( 2 | "theme_apa()" 3 | , { 4 | output_theme <- theme_apa() 5 | 6 | expect_is(output_theme, c("theme", "gg")) 7 | } 8 | ) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_transmute_df_into_label.R: -------------------------------------------------------------------------------- 1 | 2 | options(papaja.mse = TRUE) 3 | 4 | test_that( 5 | "transmute_df_into_label()" 6 | , { 7 | # only one df, non-integer df, update label and remove extraneous column: 8 | t_out1 <- apa_print(t.test(formula = yield ~ N, data = npk)) 9 | 10 | fused_1 <- transmute_df_into_label(t_out1) 11 | expect_identical( 12 | variable_label(fused_1$table$statistic) 13 | , "$t(21.88)$" 14 | ) 15 | expect_identical( 16 | colnames(fused_1$table) 17 | , c("estimate", "conf.int", "statistic", "p.value") 18 | ) 19 | 20 | # only one df, integer df, update label and remove extraneous column: 21 | t_out2 <- apa_print(t.test(formula = yield ~ N, data = npk, var.equal = TRUE)) 22 | 23 | fused_2 <- transmute_df_into_label(t_out2) 24 | expect_identical( 25 | variable_label(fused_2$table$statistic) 26 | , "$t(22)$" 27 | ) 28 | expect_identical( 29 | colnames(fused_2$table) 30 | , c("estimate", "conf.int", "statistic", "p.value") 31 | ) 32 | 33 | # same df for multiple terms, update label and remove extraneous columns: 34 | between_anova_out <- apa_print(aov(yield ~ N*P, data = npk), estimate = "pes") 35 | 36 | fused_out <- transmute_df_into_label(between_anova_out) 37 | expect_identical( 38 | tinylabels::variable_label(fused_out$table$statistic) 39 | , "$F(1, 20)$" 40 | ) 41 | expect_identical( 42 | colnames(fused_out$table) 43 | , c("term", "estimate", "statistic", "mse", "p.value") 44 | ) 45 | 46 | # df vary by term, should result in an error when trying to fuse: 47 | npk2 <- rbind(npk, npk) 48 | npk2$N <- factor(as.integer(npk2$N) + rep(c(0, 2), each = nrow(npk))) 49 | between_anova_out <- apa_print(aov(yield ~ N*P, data = npk2), estimate = "pes") 50 | expect_error( 51 | transmute_df_into_label(between_anova_out) 52 | , fixed = TRUE 53 | , regexp = "Degrees of freedom (in column 'df') vary across table rows." 54 | ) 55 | 56 | multiple_df <- rbind(t_out1$table, t_out2$table) 57 | expect_error( 58 | transmute_df_into_label(multiple_df) 59 | , regexp = "Degrees of freedom (in column 'df') vary across table rows." 60 | , fixed = TRUE 61 | ) 62 | 63 | noninteger_df <- rbind(t_out1$table, t_out1$table) 64 | expect_warning( 65 | transmute_df_into_label(noninteger_df) 66 | , regexp = "Column 'df' contains non-integer values." 67 | , fixed = TRUE 68 | ) 69 | 70 | # If no df columns are present in 'x', simply return 'x' but throw a message 71 | # if check_df = FALSE 72 | apa_no_df <- apa_print(wilcox.test(yield ~ N, data = npk, exact = F)) 73 | 74 | # No message if check_df == FALSE: 75 | junk <- transmute_df_into_label(apa_no_df, check_df = FALSE) 76 | 77 | # By default, expect an informative message: 78 | expect_message( 79 | fused_out <- transmute_df_into_label(apa_no_df) 80 | , fixed = TRUE 81 | , regexp = "There are no df columns to transmute. Returning original input." 82 | ) 83 | # Also check that x is not modified: 84 | expect_identical( 85 | apa_no_df 86 | , fused_out 87 | ) 88 | } 89 | ) 90 | -------------------------------------------------------------------------------- /tests/testthat/test_utils_for_plots.R: -------------------------------------------------------------------------------- 1 | context("tex_conv borderline cases") 2 | 3 | test_that( 4 | "tex_conv() borderline cases" 5 | , { 6 | object_1 <- expression(test) 7 | object_2 <- tex_conv(object_1) 8 | object_3 <- "a" 9 | object_4 <- tex_conv(object_3, latex2exp = FALSE) 10 | 11 | expect_identical( 12 | object = object_2 13 | , expected = object_1[[1]] 14 | ) 15 | expect_identical( 16 | object = object_4 17 | , expected = as.expression(object_3)[[1]] 18 | ) 19 | } 20 | ) 21 | -------------------------------------------------------------------------------- /tools/images/papaja_hex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/tools/images/papaja_hex.png -------------------------------------------------------------------------------- /update_csl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script is adaptation of Brenton Wiernik's script at retrieved from 4 | # https://github.com/bwiernik/zotero-tools 5 | 6 | cd inst/rmd 7 | 8 | # Remove previous versions 9 | for i in {6..7} 10 | do 11 | rm -f apa$i.csl apa$i-no-disambiguation.csl apa$i-annotated.csl apa$i-annotated-no-disambiguation.csl 12 | done 13 | 14 | # Download latest CSL files 15 | curl -sS "https://raw.githubusercontent.com/citation-style-language/styles/master/apa-6th-edition.csl" --output "apa6.csl" 16 | curl -sS "https://raw.githubusercontent.com/citation-style-language/styles/master/apa.csl" --output "apa7.csl" 17 | 18 | # Create variants 19 | for i in {6..7} 20 | do 21 | sed -e 's//\ 22 | /' -e "s/American Psychological Association ${i}th edition/American Psychological Association ${i}th edition (annotated)/g" -e 's/styles\/apa/styles\/apa-annotated/g' -e 's/rel="self"\/>/rel="self"\/>\ 23 | /g'apa$i-annotated.csl 24 | for j in '' '-annotated' 25 | do sed -e 's/disambiguate-add-givenname="true"//g' -e 's/disambiguate-add-givenname="true"//g' -e 's/givenname-disambiguation-rule="primary-name"//g' -e "s/American Psychological Association 6th edition\( *(*\)\([^\)<]*\))*/American Psychological Association ${i}th edition (\2without given name disambiguation)/g" -e "s/(annotatedwithout/(annotated without/g" -e "s/styles\/apa/styles\/apa${j}-no-disambiguation/g" -e 's/rel="self"\/>/rel="self"\/>\n /g'apa$i$j-no-disambiguation.csl 26 | done 27 | done 28 | 29 | cd ../.. 30 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/papaja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crsh/papaja/18484f486454d7ef9b6f3dfa1990e262269b6278/vignettes/papaja.pdf -------------------------------------------------------------------------------- /vignettes/papaja.pdf.asis: -------------------------------------------------------------------------------- 1 | %\VignetteIndexEntry{Prepare APA Journal Articles with R Markdown} 2 | %\VignetteEngine{R.rsp::asis} 3 | %\VignetteKeyword{PDF} 4 | -------------------------------------------------------------------------------- /vignettes/r-references.bib: -------------------------------------------------------------------------------- 1 | @Manual{R-afex, 2 | title = {afex: Analysis of Factorial Experiments}, 3 | author = {Henrik Singmann and Ben Bolker and Jake Westfall and Frederik Aust and Mattan S. Ben-Shachar}, 4 | year = {2021}, 5 | note = {R package version 1.0-1}, 6 | url = {https://CRAN.R-project.org/package=afex}, 7 | } 8 | @Manual{R-base, 9 | title = {R: A Language and Environment for Statistical Computing}, 10 | author = {{R Core Team}}, 11 | organization = {R Foundation for Statistical Computing}, 12 | address = {Vienna, Austria}, 13 | year = {2021}, 14 | url = {https://www.R-project.org/}, 15 | } 16 | @Manual{R-dplyr, 17 | title = {dplyr: A Grammar of Data Manipulation}, 18 | author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller}, 19 | year = {2022}, 20 | note = {R package version 1.0.8}, 21 | url = {https://CRAN.R-project.org/package=dplyr}, 22 | } 23 | @Manual{R-ggforce, 24 | title = {ggforce: Accelerating 'ggplot2'}, 25 | author = {Thomas Lin Pedersen}, 26 | year = {2021}, 27 | note = {R package version 0.3.3}, 28 | url = {https://CRAN.R-project.org/package=ggforce}, 29 | } 30 | @Book{R-ggplot2, 31 | author = {Hadley Wickham}, 32 | title = {ggplot2: Elegant Graphics for Data Analysis}, 33 | publisher = {Springer-Verlag New York}, 34 | year = {2016}, 35 | isbn = {978-3-319-24277-4}, 36 | url = {https://ggplot2.tidyverse.org}, 37 | } 38 | @Article{R-lme4, 39 | title = {Fitting Linear Mixed-Effects Models Using {lme4}}, 40 | author = {Douglas Bates and Martin M{\"a}chler and Ben Bolker and Steve Walker}, 41 | journal = {Journal of Statistical Software}, 42 | year = {2015}, 43 | volume = {67}, 44 | number = {1}, 45 | pages = {1--48}, 46 | doi = {10.18637/jss.v067.i01}, 47 | } 48 | @Manual{R-Matrix, 49 | title = {Matrix: Sparse and Dense Matrix Classes and Methods}, 50 | author = {Douglas Bates and Martin Maechler}, 51 | year = {2021}, 52 | note = {R package version 1.3-4}, 53 | url = {https://CRAN.R-project.org/package=Matrix}, 54 | } 55 | @Manual{R-papaja, 56 | title = {{papaja}: {Prepare} reproducible {APA} journal articles with {R Markdown}}, 57 | author = {Frederik Aust and Marius Barth}, 58 | year = {2022}, 59 | note = {R package version 0.2.0}, 60 | url = {https://github.com/crsh/papaja}, 61 | } 62 | @Manual{R-tinylabels, 63 | title = {{tinylabels}: Lightweight Variable Labels}, 64 | author = {Marius Barth}, 65 | year = {2022}, 66 | note = {R package version 0.2.3}, 67 | url = {https://cran.r-project.org/package=tinylabels}, 68 | } 69 | --------------------------------------------------------------------------------