-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Ability to ignore "not enough finite observations" error #100
Comments
Hi, would you have a reproducible example so that we can resolve that? Thanks! |
|
Yes, that's because you can't compute a correlation with only 2 observations (2 complete rows). If you add one row it works: library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.0.2
library(correlation)
tibble(v2 = c(2, 1, 1, 2, 2), v3 = c(1,2, NA, NA, 3)) %>%
correlation()
#> Parameter1 | Parameter2 | r | t | df | p | Method | n_Obs
#> ---------------------------------------------------------------------
#> v2 | v3 | 0.00 | 0.00 | 1 | > .999 | Pearson | 3 Created on 2020-09-22 by the reprex package (v0.3.0) |
I understand why it can't be calculated. I am interested in the ability to ignore it. For example, say I have a table with 1000 elements and would like to calculate all correlations. It would be very easy to use correlation::correlation() for that. But if some pairs have too few observations, it gives this error, so the method can't be used. |
I see! Indeed, it would be better to return NA with a warning than throw an error that stops the process. Let me see what I can do. |
correlation calls cor.test.default which gives a not enough finite observation error when applicable. I think there could be a value in correlation() such as ignore_errors that sets those to NA instead.
The text was updated successfully, but these errors were encountered: