Skip to content

Conversation

@ianhussey
Copy link

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.

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.
Copy link

@gemini-code-assist gemini-code-assist bot left a 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_zero argument: A new boolean argument, leading_zero, has been introduced to the format_p function. By default, this argument is set to FALSE, which enables the new behavior of removing leading zeros.
  • Consistent leading zero removal: The format_p function now consistently removes the leading zero before the decimal separator for all p-values when leading_zero is FALSE. 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_p function 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@strengejacke
Copy link
Member

Thanks! A couple of comments. Could you also increase the dev-version number in the DESCRIPTION file? And please add a small test.

@ianhussey
Copy link
Author

ianhussey commented Aug 26, 2025 via email

@strengejacke
Copy link
Member

Don't worry, I can add tests. Could you please look at my comments?

@bwiernik
Copy link
Contributor

For consistency, I think we should include a leading zero in the truncated format "p < 0.001" when leading_zero = TRUE

@strengejacke
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants