ggobi / ggally

R package that extends ggplot2
http://ggobi.github.io/ggally/
588 stars 118 forks source link

ggally_cor errors out if number of samples is less than 3 rather than returning NA #480

Open janlimbeck opened 10 months ago

janlimbeck commented 10 months ago

When calling ggally_cor on data sets with less than 3 samples the function errors out due cor.test.default requiring more than 2 samples. It would be better if the function would not fail hard but return NA instead since ggally_cor is also used within ggpairs which would then also fail if used in conjunction with a mapping that leads to combinations with less than 3 samples.

library(GGally)
data(tips, package = "reshape")
ggally_cor(tips[1:2, ], mapping = ggplot2::aes_string(x = "total_bill", y = "tip"))