 <p>You can accomplish the feat with limma, also. See the example below.</p> <p>The idea is basically exactly the same as in the code you have posted, but it has not been wrapped into a function (and is therefore possibly slightly easier to debug). </p> <p>Do you get it to work with the code below? If not, please post the possible error messages and warnings that you get.</p> <pre><code># Load the library library(limma) # Generate example data set1&lt;-letters[1:5] set2&lt;-letters[4:8] set3&lt;-letters[5:9] # What are the possible letters in the universe? universe &lt;- sort(unique(c(set1, set2, set3))) # Generate a matrix, with the sets in columns and possible letters on rows Counts &lt;- matrix(0, nrow=length(universe), ncol=3) # Populate the said matrix for (i in 1:length(universe)) { Counts[i,1] &lt;- universe[i] %in% set1 Counts[i,2] &lt;- universe[i] %in% set2 Counts[i,3] &lt;- universe[i] %in% set3 } # Name the columns with the sample names colnames(Counts) &lt;- c("set1","set2","set3") # Specify the colors for the sets cols&lt;-c("Red", "Green", "Blue") vennDiagram(vennCounts(Counts), circle.col=cols) </code></pre> <p>The code should give a plot similar to:</p> <p><img src="https://i.stack.imgur.com/lu3rb.jpg" alt="enter image description here"></p>