{"id":27642229,"url":"https://github.com/m-py/prmisc","last_synced_at":"2025-04-23T23:53:42.068Z","repository":{"id":49164143,"uuid":"124881744","full_name":"m-Py/prmisc","owner":"m-Py","description":"Miscellaneous printing of stat results in Rmarkdown","archived":false,"fork":false,"pushed_at":"2025-03-13T13:25:57.000Z","size":177,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T23:53:38.553Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m-Py.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-12T11:54:19.000Z","updated_at":"2025-03-17T13:54:16.000Z","dependencies_parsed_at":"2025-02-27T11:44:52.365Z","dependency_job_id":"6b0e39e3-57e9-4c21-a2a8-25c74ade3e09","html_url":"https://github.com/m-Py/prmisc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-Py%2Fprmisc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-Py%2Fprmisc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-Py%2Fprmisc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-Py%2Fprmisc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m-Py","download_url":"https://codeload.github.com/m-Py/prmisc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535071,"owners_count":21446506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-23T23:53:41.083Z","updated_at":"2025-04-23T23:53:42.048Z","avatar_url":"https://github.com/m-Py.png","language":"R","readme":"# prmisc\n\nMiscellaneous printing of statistical results in Rmarkdown according to APA style guidelines. This package covers some basic statistical tests (t-test, ANOVA, correlation, chi-squared test) and some basic number printing manipulations (formatting p-values, removing leading zeros for numbers that cannot be greater than one, and others). Other functions for printing statistical tests and numbers can be found in the R packages [apa](https://cran.r-project.org/package=apa) and [papaja](https://cran.r-project.org/package=papaja).\n\n# Installation\n\nprmisc is available from [CRAN](https://cran.r-project.org/package=prmisc) and can be installed via `install.packages()`:\n\n```R\ninstall.packages(\"prmisc\")\n```\n\n# Usage\n\n## t.test\n\n```R\nttest \u003c- t.test(1:10, y = c(7:20), var.equal = TRUE)\nlibrary(\"effectsize\") # for Cohen's d\ncohend \u003c- cohens_d(1:10, c(7:20))\nprint_ttest(ttest, cohend) # include this call in Rmd inline code\n\n# [1] \"$t(22) = -5.15$, $p \u003c .001$, $d = -2.13$\"\n\n# An example for paired data:\ndata(sleep) # ?sleep\ntt \u003c- t.test(sleep$extra[sleep$group == 1], \n             sleep$extra[sleep$group == 2], paired = TRUE)\ncd \u003c- cohens_d(sleep$extra[sleep$group == 1], \n               sleep$extra[sleep$group == 2], paired = TRUE)\nprint_ttest(tt, cd)\n# \"$t(9) = -4.06$, $p = .003$, $d_z = -1.28$\"\n\n# Print the confidence interval:\nprint_ttest(tt, cd, confidence = TRUE)\n# \"$t(9) = -4.06$, $p = .003$, $d_z = -1.28$, $95\\\\%$ $CI$ $[-2.12$, $-0.41]$\"\n\n# The information about the CI is taken from the effectsize object:\ncd \u003c- cohens_d(sleep$extra[sleep$group == 1], \n               sleep$extra[sleep$group == 2], paired = TRUE, ci = .8)\nprint_ttest(tt, cd, confidence = TRUE)\n# \"$t(9) = -4.06$, $p = .003$, $d_z = -1.28$, $80\\\\%$ $CI$ $[-1.81$, $-0.70]$\"\n\n# effect size object can be left out:\nprint_ttest(tt)\n# \"$t(9) = -4.06$, $p = .003$\"\n\n# Each function includes documentation via the R help:\n?print_ttest\n```\n\n## chi-square-test\n\n```R\nx \u003c- matrix(c(12, 5, 7, 7), ncol = 2)\nprint_chi2(x) # does not use continuity correction by default\n# [1] \"$\\\\chi^2(1, N = 31) = 1.37$, $p = .242$, $\\\\phi = .21$\"\n\nprint_chi2(x, correct = TRUE) # use continuity correction\n# [1] \"$\\\\chi^2(1, N = 31) = 0.64$, $p = .423$, $\\\\phi = .14$\"\n```\n\n## Correlation coefficient\n\n```R\nx \u003c- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)\ny \u003c- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)\ncor_results \u003c- cor.test(x, y)\n\nprint_cortest(cor_results)\n# [1] \"$r(7) = .57$, $p = .108$\"\n```\n\n## ANOVA\n\n```R\nlibrary(\"afex\")\n# see ?aov_ez\ndata(md_12.1)\naov_results \u003c- aov_ez(\"id\", \"rt\", md_12.1, within = c(\"angle\", \"noise\"))\n\nprint_anova(aov_results) # returns a list with all effects in this ANOVA\n# $angle\n# [1] \"$F(1.92$, $17.31) = 40.72$, $p \u003c .001$, $\\\\eta_G^2 = .39$\"\n# \n# $noise\n# [1] \"$F(1$, $9) = 33.77$, $p \u003c .001$, $\\\\eta_G^2 = .39$\"\n# \n# $`angle:noise`\n# [1] \"$F(1.81$, $16.27) = 45.31$, $p \u003c .001$, $\\\\eta_G^2 = .19$\"\n\n## Print nonitalic eta, which is required according to APA guidelines\nprint_anova(aov_results, italic_eta = FALSE)\n# $angle\n# [1] \"$F(1.92$, $17.31) = 40.72$, $p \u003c .001$, $\\\\upeta_\\\\mathrm{G}^2 = .39$\"\n#\n# $noise\n# [1] \"$F(1$, $9) = 33.77$, $p \u003c .001$, $\\\\upeta_\\\\mathrm{G}^2 = .39$\"\n# \n# $`angle:noise`\n# [1] \"$F(1.81$, $16.27) = 45.31$, $p \u003c .001$, $\\\\upeta_\\\\mathrm{G}^2 = .19$\"\n\n\n## Example using other (or no) effect size index (output not shown)\nprint_anova(aov_ez(\"id\", \"rt\", md_12.1, within = c(\"angle\", \"noise\"),\n                   anova_table = list(es = \"pes\")))\nprint_anova(aov_ez(\"id\", \"rt\", md_12.1, within = c(\"angle\", \"noise\"),\n                   anova_table = list(es = \"none\")))\n\n```\n\n## Some functions for printing numbers\n\n```R\nforce_decimals(c(1.23456, 0.873, 2.3456), decimals = 2)\n# [1] \"1.23\" \"0.87\" \"2.35\"\n## Note that the function `round()` will not produce the same results as\n## force_decimals in Rmd output\n\nforce_decimals(c(0.004, 0.001, 0.0005, 0.02))\n# [1] \"0.00\" \"0.00\" \"0.00\" \"0.02\"\n## Small numbers are rounded to zero by default.\n## This behaviour can be controlled using the argument `round_zero`:\nforce_decimals(c(0.004, 0.001, 0.0005, 0.02), round_zero = FALSE)\n# \"\u003c 0.01\" \"\u003c 0.01\" \"\u003c 0.01\" \"0.02\"\n\n## Leave integers intact:\nforce_or_cut(c(1:3, 1.23456, 0.873, 2.3456), decimals = 2)\n# [1] \"1\"    \"2\"    \"3\"    \"1.23\" \"0.87\" \"2.35\"\n## Compare:\nforce_decimals(c(1:3, 1.23456, 0.873, 2.3456), decimals = 2)\n# [1] \"1.00\" \"2.00\" \"3.00\" \"1.23\" \"0.87\" \"2.35\"\n\n## Show only decimals (e.g., for p-values or correlation coefficients)\ndecimals_only(c(0.23456, 0.873, 0.3456), decimals = 3)\n# [1] \".235\" \".873\" \".346\"\n\n## Format a p-value, default is 3 decimals\nformat_p(0.03123)\n# [1] \"$p = .031$\"\n\nformat_p(0.000001231, 3)\n# [1] \"$p \u003c .001$\"\n\nformat_p(0.3123, decimals = 2)\n# [1] \"$p = .31$\"\n\n## Format several p-values with one function call\nformat_p(c(0.3123, 0.001, 0.00001, 0.19))\n# [1] \"$p = .312$\" \"$p = .001$\" \"$p \u003c .001$\" \"$p = .190$\"\n\nformat_p(c(.999, .9999, 1))\n# [1] \"$p = .999$\" \"$p \u003e .999$\" \"$p \u003e .999$\"\n\n## Number printing functions have two decimals by default, \n## but format_p has three decimals by default\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-py%2Fprmisc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm-py%2Fprmisc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-py%2Fprmisc/lists"}