Skip to content
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

printp(x) output is inconsistent when x has values greater & smaller than .001 #313

Closed
mvuorre opened this issue Sep 5, 2019 · 4 comments

Comments

@mvuorre
Copy link

mvuorre commented Sep 5, 2019

Currently, if you run printp(x) on x that contains values both above and below the threshold of 0.001, you get inconsistent output values, some of which contain an operator and some don't. This is especially problematic if you're e.g. constructing a variable that has p values from several tests that you'd like to report together (in a table or in text).

library(papaja)

ps <- c(1, .05, .00001, NA)
printp(ps)
#> [1] "> .999" ".050"   "< .001" ""

# Reporting in text can result in two operators
paste0("Test ", 1:4, ": p = ", printp(ps))
#> [1] "Test 1: p = > .999" "Test 2: p = .050"   "Test 3: p = < .001"
#> [4] "Test 4: p = "
# or some without equals sign
paste0("Test ", 1:4, ": p ", printp(ps))
#> [1] "Test 1: p > .999" "Test 2: p .050"   "Test 3: p < .001"
#> [4] "Test 4: p "

# New feature is suggested in my fork's devel branch
# remotes::install_github("mvuorre/papaja@devel")
printp(ps, add_eq = TRUE)
#> [1] "> .999" "= .050" "< .001" ""

# Default is add_eq = FALSE, which gives old behavior
printp(ps)
#> [1] "> .999" ".050"   "< .001" ""

Created on 2019-09-05 by the reprex package (v0.3.0.9000)

See the commit here.

An additional benefit of including those extra two lines of code in printp() is that you could remove quite a bit of code that does the same in thing in various apa_print* methods (e.g. here) and instead replace them with printp(p, add_eq = TRUE)

@crsh
Copy link
Owner

crsh commented Sep 5, 2019

Hi Matti, thanks for the suggestion. That makes sense to me. I think, it would even make sense to add this to printnum() since printp() is just a shortcut. Addition of an equal symbol could be useful in printnum() as well when zero = FALSE or gt1 = FALSE, right?

@mariusbarth, what do you think about this? This would be a more general alternative to your proposed add_equals() in #310, right?

@mvuorre
Copy link
Author

mvuorre commented Sep 5, 2019

Great, yes it looks like you'd want to put it in printnum().

mariusbarth added a commit to mariusbarth/papaja that referenced this issue Oct 18, 2019
- defaults to `FALSE`
- is implemented by calling internal function `add_equals()`
@crsh
Copy link
Owner

crsh commented Nov 21, 2019

@mariusbarth, you worked on this right? Could you summarize how you solved this (maybe in reference to the above example)?

@mariusbarth
Copy link
Collaborator

Sure! On the development branch, I basically implemented what Matti suggested: Both printp() and the printnum.numeric() method now have an additional argument add_equals which defaults to FALSE. Therefore, both functions by default show their previous behavior. If, instead, you want a consistent output which is always prepended by either =, <, >, then you choose add_equals = TRUE. Hope this is exactly what you wished for.

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

No branches or pull requests

3 participants