-
-
Notifications
You must be signed in to change notification settings - Fork 41
Update format_p.R to remove leading zeros consistently #1123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Previously, leading zeros were only removed when the value was truncated. `format_p(.02)` would return "p = 0.02" but `format_p(.00002)` would return "p < .001". APA style suggests always dropping leading zeros from p-values. This commit adds a new argument, leading_zeros, which defaults to FALSE. When FALSE, a `gsub()` call removes the leading zero before the decimal_seperator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ianhussey, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request refines the format_p function to ensure consistent adherence to APA style guidelines regarding the display of p-values. The primary change involves modifying how leading zeros are handled, making their removal a default behavior rather than being conditional on truncation. This enhancement improves the uniformity and readability of formatted p-values across all cases.
Highlights
- New
leading_zeroargument: A new boolean argument,leading_zero, has been introduced to theformat_pfunction. By default, this argument is set toFALSE, which enables the new behavior of removing leading zeros. - Consistent leading zero removal: The
format_pfunction now consistently removes the leading zero before the decimal separator for all p-values whenleading_zeroisFALSE. Previously, this removal only occurred when the p-value was truncated (e.g., 'p < .001'). - Enhanced APA style compliance: This change ensures that the
format_pfunction adheres more closely to APA style guidelines, which suggest always dropping leading zeros from p-values for improved readability and consistency.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new leading_zero argument to format_p() to control the display of leading zeros for p-values, aligning with APA style guidelines. The implementation uses a robust regular expression to handle various p-value formats and custom decimal separators.
My review found a critical issue where the new logic will cause a runtime error due to a variable scoping problem. I've also pointed out a minor typo in the documentation. Once the critical issue is addressed, this change will be a valuable improvement.
|
Thanks! A couple of comments. Could you also increase the dev-version number in the |
|
I’m sorry to plead ignorance but I have no knowledge or experience writing tests. This package and the admin structures around it are clearly a much more professional enterprise than I have experience with..
… On 25 Aug 2025, at 16:26, Daniel ***@***.***> wrote:
strengejacke
left a comment
(easystats/insight#1123)
<#1123 (comment)>
Thanks! A couple of comments. Could you also increase the dev-version number in the DESCRIPTION file? And please add a small test.
—
Reply to this email directly, view it on GitHub <#1123 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABLWCEB5CEAHK64YP6LK4GD3PMMJVAVCNFSM6AAAAACEX6KPDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMRQGUYTSOBWGE>.
You are receiving this because you were mentioned.
|
|
Don't worry, I can add tests. Could you please look at my comments? |
|
For consistency, I think we should include a leading zero in the truncated format |
|
Yes, that should already work. In general, this is a breaking change that will affect all outputs and all snapshot tests. @DominiqueMakowski what do you think about this PR? |
Previously, leading zeros were only removed when the value was truncated.
format_p(.02)would return "p = 0.02" butformat_p(.00002)would return "p < .001". APA style suggests always dropping leading zeros from p-values. This commit adds a new argument, leading_zeros, which defaults to FALSE. When FALSE, agsub()call removes the leading zero before the decimal_seperator.