Package ‘eulerr’ June 20, 2017 Title Area-Proportional Euler Diagrams Version 2.0.0 Description If possible, generates exactly area-proportional Euler diagrams, or otherwise approximately proportional diagrams using numerical optimization. A Euler diagram is a generalization of a Venn diagram, relaxing the criterion that all interactions need to be represented. Depends R (>= 3.3.1) Imports graphics, grDevices, grid, stats, utils, assertthat, lattice, Rcpp Suggests knitr, rmarkdown, testthat LinkingTo Rcpp (>= 0.12.8), RcppArmadillo (>= 0.7.600.1.0) License GPL-3 Encoding UTF-8 LazyData true VignetteBuilder knitr URL https://github.com/jolars/eulerr BugReports https://github.com/jolars/eulerr/issues RoxygenNote 6.0.1 NeedsCompilation yes Author Johan Larsson [aut, cre], A. Jonathan R. Godfrey [ctb] Maintainer Johan Larsson <[email protected]> Repository CRAN Date/Publication 2017-06-20 20:41:29 UTC R topics documented: euler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . eulerr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 5 2 euler panel.euler . . . . panel.euler.circles panel.euler.labels plot.euler . . . . prepanel.euler . . print.euler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index euler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 . 6 . 7 . 8 . 10 . 10 12 Area-Proportional Euler Diagrams Description Fit euler diagrams (a generalization of venn diagrams) using numerical optimization to find exact or approximate solutions to a specification of set relationships. Usage euler(combinations, ...) ## Default S3 method: euler(combinations, input = c("disjoint", "union"), ...) ## S3 method for class 'data.frame' euler(combinations, weights = NULL, by = NULL, ...) ## S3 method for class 'matrix' euler(combinations, ...) ## S3 method for class 'table' euler(combinations, ...) ## S3 method for class 'list' euler(combinations, ...) Arguments combinations Set relationships as a named numeric vector, matrix, or data.frame. (See the methods (by class) section for details.) ... Arguments passed down to other methods. input The type of input: disjoint class combinations (disjoint) or unions (union). weights A numeric vector of weights of the same length as by and the number of rows in combinations. by A factor or character matrix to be used in base::by() to split the data.frame or matrix of set combinations. euler 3 Details If the input is a matrix or data frame and argument by is specified, the function returns a list of euler diagrams. The function minimizes the sums of squared errors between the disjoint areas in the euler diagram and the user’s input, namely n X (yi − ŷi )2 , i=1 where ŷ are estimates of y that are currently being explored. The stress statistic from venneuler is returned to give an indication of the goodness of the fit: Pn (y − ŷ )2 i=1 Pn i 2 i , i=1 yi where ŷ are ordinary least squares estimates from the regression of the fitted areas on the original areas that are currently being explored. euler() also returns diag_error and region_error from eulerAPE. region_error is computed as yi P − Pŷi . yi ŷi diag_error is simply the maximum of region_error. Value A list object of class ’euler’ with the following parameters. coefficients A matrix of x and y coordinates for the centers of the circles and their radii. original.values Set relationships provided by the user. fitted.values Set relationships in the solution. residuals Residuals. diag_error The largest absolute residual in percentage points between the original and fitted areas. stress The stress of the solution, computed as the sum of squared residuals over the total sum of squares. Methods (by class) • default: A named numeric vector, with combinations separated by an ampersand, for instance A&B = 10. Missing combinations are treated as being 0. • data.frame: A data.frame of logicals, two-level factors (see examples). • matrix: A matrix that can be converted to a data.frame of logicals (as in the description above) via base::as.data.frame.matrix(). • table: A table with max(dim(x)) < 3. • list: A list of vectors, each vector giving the contents of that set. Vectors in the list do not need to be named. 4 euler References Wilkinson L. Exact and Approximate Area-Proportional Circular Venn and Euler Diagrams. IEEE Transactions on Visualization and Computer Graphics (Internet). 2012 Feb (cited 2016 Apr 9);18(2):321–31. Available from: http://doi.org/10.1109/TVCG.2011.56 Micallef L, Rodgers P. eulerAPE: Drawing Area-Proportional 3-Venn Diagrams Using Ellipses. PLOS ONE (Internet). 2014 Jul (cited 2016 Dec 10);9(7):e101717. Available from: http://dx. doi.org/10.1371/journal.pone.0101717 See Also plot.euler(), print.euler() Examples # First fit the euler specification fit <- euler(c("A" = 1, "B" = 0.4, "C" = 3, "A&B" = 0.2)) # Then plot it plot(fit) # Same result as above euler(c("A" = 1, "B" = 0.4, "C" = 3, "A&B" = 0.2, "A&C" = 0, "B&C" = 0, "A&B&C" = 0)) # 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"))) # 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) # Using grouping via the 'by' argument 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[, 1:2], by = dat[, 3:4]) # 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)) # The table method eulerr 5 plot(euler(as.table(apply(Titanic, 2:4, sum)))) eulerr Area-Proportional Euler Diagrams (defunct) Description Note: This function is defunct; please use euler() instead. Usage eulerr(...) Arguments ... Ignored panel.euler Panel Function for Euler Diagrams Description Panel Function for Euler Diagrams Usage panel.euler(x, y, r, subscripts, fill = superpose.polygon$col, lty = superpose.polygon$lty, lwd = superpose.polygon$lwd, border = superpose.polygon$border, alpha = superpose.polygon$alpha, fontface = "bold", counts = TRUE, labels = NULL, original.values, fitted.values, ...) Arguments x X coordinates for the circle centers. y Y coordinates for the circle centers. r Radii. subscripts A vector of subscripts (See lattice::xyplot()). fill Fill color for circles. (See grid::gpar().) lty Line type for circles. (See grid::gpar().) lwd Line weight for circles. (See grid::gpar().) border Border color for circles. 6 panel.euler.circles alpha Alpha for circles. Note that plot.euler() by default modifies the alpha of col instead to avoid affecting the alpha of the borders. (See grid::gpar().) fontface Fontface for the labels. (See grid::gpar().) counts Plots the original values for the disjoint set combinations (original.values). Can also be a list, in which the contents of the list will be passed on to lattice::panel.text() to modify the appearance of the counts. labels Labels to plot on the circles. original.values Original values for the disjoint set combinations. fitted.values Fitted values for the disjoint set combinations. ... Passed down to panel.euler.circles() and panel.euler.labels(). Value Plots euler diagrams inside a trellis panel. See Also grid::gpar(). panel.euler.circles Panel Function for Circles Description Panel Function for Circles Usage panel.euler.circles(x, y, r, border = "black", fill = "transparent", ..., identifier = NULL, name.type = "panel", col, font, fontface) Arguments x X coordinates for the circle centers. y Y coordinates for the circle centers. r Radii. border Border color. fill Circle fill. ... Passed on to grid::grid.circle(). identifier A character string that is prepended to the name of the grob that is created. name.type A character value indicating whether the name of the grob should have panel or strip information added to it. Typically either "panel", "strip", "strip.left", or "" (for no extra information). panel.euler.labels 7 col Ignored font Ignored fontface Ignored Value Plots circles inside a trellis panel. See Also grid::grid.circle(). panel.euler.labels Panel Function for Circle Labels Description Panel Function for Circle Labels Usage panel.euler.labels(x, y, r, labels, counts = TRUE, original.values, fitted.values, ...) Arguments x X coordinates for the circle centers. y Y coordinates for the circle centers. r Radii. labels Labels to plot on the circles. counts Plots the original values for the disjoint set combinations (original.values). Can also be a list, in which the contents of the list will be passed on to lattice::panel.text() to modify the appearance of the counts. original.values Original values for the disjoint set combinations. fitted.values Fitted values for the disjoint set combinations. ... Arguments passed on to panel.text() Value Computes and plots labels or counts inside the centers of the circles’ overlaps. 8 plot.euler plot.euler Plot Area-Proportional Euler Diagrams Description Plot Euler diagrams with trellis graphics from lattice. This function calls lattice::xyplot() under the hood, allowing plots of both individual euler diagrams as well as grids of diagrams in case the by argument was used in the call to euler(). Usage ## S3 method for class 'euler' plot(x, fill = qualpalr_pal, fill_alpha = 0.4, auto.key = FALSE, counts = FALSE, labels = is.logical(auto.key) && !isTRUE(auto.key), fontface = "bold", par.settings = list(), ..., default.prepanel = prepanel.euler, default.scales = list(draw = FALSE), panel = panel.euler, outer_strips, fill_opacity) Arguments x An object of class euler. fill Fill color. Either a function that takes as its first argument the number of colors to generate, or a sequence of colors. fill_alpha Alpha for the fill. auto.key Plot a legend for the sets. counts Plot counts. labels A list or character vector of labels. fontface Fontface for the labels. (See grid::gpar()). par.settings Graphical parameters for trellis displays. See lattice::trellis.par.get(). ... Arguments to pass down to panel.euler(), which in turn passes them down to panel.euler.circles() and panel.euler.labels(). default.prepanel Default prepanel function. Should usually be left untouched. default.scales Default scales. Turns off panel The panel function. Should usually be left untouched. outer_strips Deprecated fill_opacity Deprecated plot.euler 9 Details Almost all of the relevant functionality for lattice::xyplot() is available here. For instance, providing specifications to par.settings will have an effect on many aspects of the plot. Moreover, arguments that are given here will trickle down to the panel function panel.euler() and subsequently to panel.euler.circles() and panel.euler.labels(), which do the actual plotting. The default value for fill causes, eulerr to choose color palettes based on the number of sets, trying to provide palettes adapted to color vision deficiencies based on qualpalr::qualpal(). Value An object of class "trellis". The update method can be used to update components of the object and the print method (usually called by default) will plot it on an appropriate plotting device. See Also panel.euler.circles(), panel.euler.labels(), lattice::xyplot(), grid::gpar(), grid::grid.circle(), lattice::panel.xyplot(), euler(), qualpalr::qualpal() Examples fit <- euler(c("A" = 10, "B" = 5, "A&B" = 3)) plot(fit, labels = c("foo", "bar"), fill_alpha = 0.7) # Customize colors, remove borders, bump alpha, color labels white plot(fit, fill_alpha = 0.5, fill = c("red", "steelblue4"), col = "white", border = "transparent", fontface = "bold.italic") # Add counts to the plot plot(fit, counts = TRUE) # Add a custom legend and retain counts plot(fit, counts = TRUE, auto.key = list(space = "bottom", columns = 2)) # Plot without fills and distinguish sets with border types instead plot(fit, lty = c("solid", "dotted"), fill = "transparent", cex = 2, fontface = 2, labels = c("foo", "bar")) # Plot a grid of euler plots 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) ) gridfit <- euler(dat[, 1:2], by = dat[, 3:4]) plot(gridfit, auto.key = TRUE) 10 print.euler # We can modify the grid layout as well plot(gridfit, layout = c(1, 4)) prepanel.euler Prepanel Function for Euler Diagrams Description Prepanel Function for Euler Diagrams Usage prepanel.euler(x, y, r, subscripts, ...) Arguments x X coordinates for the circle centers. y Y coordinates for the circle centers. r Radii. subscripts A vector of subscripts (See lattice::xyplot()). ... Ignored. Value A list of xlim and ylim items. print.euler Print Euler Fits Description Prints a data frame of the original set relationships and the fitted values as well as diag_error and stress statistics. Usage ## S3 method for class 'euler' print(x, round = 3, ...) Arguments x Euler diagram specification from euler(). round Number of decimal places to round to. ... Arguments passed to base::print.data.frame(). print.euler Value Prints the results of the fit. 11 Index base::as.data.frame.matrix(), 3 base::by(), 2 base::print.data.frame(), 10 euler, 2 euler(), 5, 8–10 eulerr, 5 grid::gpar(), 5, 6, 8, 9 grid::grid.circle(), 6, 7, 9 lattice::panel.text(), 6, 7 lattice::panel.xyplot(), 9 lattice::trellis.par.get(), 8 lattice::xyplot(), 5, 8–10 panel.euler, 5 panel.euler(), 8, 9 panel.euler.circles, 6 panel.euler.circles(), 6, 8, 9 panel.euler.labels, 7 panel.euler.labels(), 6, 8, 9 panel.text(), 7 plot.euler, 8 plot.euler(), 4, 6 prepanel.euler, 10 print, 9 print.euler, 10 print.euler(), 4 qualpalr::qualpal(), 9 update, 9 12
© Copyright 2026 Paperzz