Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAbility 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 | 3Created 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.