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

Improving ranktransform(sign = TRUE) #570

Closed
mattansb opened this issue Dec 8, 2024 · 3 comments · Fixed by #573
Closed

Improving ranktransform(sign = TRUE) #570

mattansb opened this issue Dec 8, 2024 · 3 comments · Fixed by #573

Comments

@mattansb
Copy link
Member

mattansb commented Dec 8, 2024

Currently, if x contains 0s, these are marked as NAs.

However, there might be situations where this is unwanted (see easystats/effectsize#502).

We can add a zeros= argument, that can take the values:

  • "na" - the current method.
  • "signrank" - keep them during the ranking and mark them as 0.
if (zeros == "na") {
  out <- rep(NA, length(x))
  ZEROES <- x == 0
  out[!ZEROES] <- sign(x[!ZEROES]) * rank(abs(x[!ZEROES]), 
                                          ties.method = method,
                                          na.last = "keep")
} else if (zeros == "signrank") {
  out <- sign(x) * rank(abs(x), ties.method = method, na.last = "keep")
}
@etiennebacher
Copy link
Member

Sounds good to me, @strengejacke @IndrajeetPatil thoughts?

@strengejacke
Copy link
Member

Agree.

@IndrajeetPatil
Copy link
Member

Thanks.

Yes, the new argument with the mentioned default sounds like a good idea to me.

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 a pull request may close this issue.

4 participants