# NOT RUN {
# Fit a diagram with circles
combo <- c(A = 2, B = 2, C = 2, "A&B" = 1, "A&C" = 1, "B&C" = 1)
fit1 <- euler(combo)
# Investigate the fit
fit1
# Refit using ellipses instead
fit2 <- euler(combo, shape = "ellipse")
# Investigate the fit again (which is now exact)
fit2
# Plot it
plot(fit2)
# A set with no perfect solution
euler(c("a" = 3491, "b" = 3409, "c" = 3503,
"a&b" = 120, "a&c" = 114, "b&c" = 132,
"a&b&c" = 50))
# Using grouping via the 'by' argument through the data.frame method
dat <- data.frame(
A = sample(c(TRUE, FALSE), size = 100, replace = TRUE),
B = sample(c(TRUE, TRUE, FALSE), size = 100, replace = TRUE),
gender = sample(c("Men", "Women"), size = 100, replace = TRUE),
nation = sample(c("Sweden", "Denmark"), size = 100, replace = TRUE)
)
euler(dat, by = list(gender, nation))
dat2 <- data.frame(A = c(TRUE, FALSE, TRUE, TRUE),
B = c(FALSE, TRUE, TRUE, FALSE))
euler(dat2, weights = c(3, 2, 1, 1))
# Using the matrix method
mat <- cbind(A = sample(c(TRUE, TRUE, FALSE), size = 50, replace = TRUE),
B = sample(c(TRUE, FALSE), size = 50, replace = TRUE))
euler(mat)
# The table method
plot(euler(as.table(apply(Titanic, 2:4, sum))))
# A euler diagram from a list of sample spaces (the list method)
euler(list(A = c("a", "ab", "ac", "abc"),
B = c("b", "ab", "bc", "abc"),
C = c("c", "ac", "bc", "abc")))
# }
Run the code above in your browser using DataLab