jolars / eulerr

Area-Proportional Euler and Venn Diagrams with Ellipses
https://jolars.github.io/eulerr/
GNU General Public License v3.0
129 stars 18 forks source link

eulerr incorrect sum #68

Closed Tobio1 closed 4 years ago

Tobio1 commented 4 years ago

Hello Johan. Thanks so much for writing eulerr. Very useful! I was hoping that you can help with the following issue. I'm quite new to R and github so please correct me if I place this wrongly and don't hesitate to contact me if you need more information.

Data x.xlsx

Code fit2 <- euler(x) plot(fit2 ,quantities = TRUE,)

Result Rplot.pdf

If I build the sum of the quantities in the Plot I get: V1: sum 58 instead of 59 V2: sum 11 instead of 12

What am I doing wrong? Thanks so much. Tobi

jolars commented 4 years ago

That's because the fit from euler is not exact. Please check the fit before plotting, i.e. do

d <- structure(list(
  V1 = c(0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 
         0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 
         1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 
         1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 
         0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 
         1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1), 
  V2 = c(0, 0, 0, 0, 
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
         0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 
         0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
         0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0), 
  V3 = c(1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
         1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 
         1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 
         1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 
         0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 
         0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1)),
  row.names = c(NA, -111L),
  class = c("data.frame")
)

f <- eulerr::euler(d)
f
#>          original fitted residuals regionError
#> V1              8      8         0       0.001
#> V2              1      1         0       0.000
#> V3             28     28         0       0.003
#> V1&V2           1      0         1       0.011
#> V1&V3          44     44         0       0.005
#> V2&V3           4      4         0       0.000
#> V1&V2&V3        6      6         0       0.001
#> 
#> diagError: 0.011 
#> stress:    0

V1&V2 is not in the fit, so it cannot be plotted. eulerr::euler(d, shape = "ellipse") will likely give you an exact fit.

Tobio1 commented 4 years ago

Thanks so much for explaining this and excuse my ignorance. Very useful!