Love-Doc R

Testing UpSetR

Imagine you want to pair your good friend Violet to a nice guy and there are some guys you already had thought about, like old Olaf, sweet Sven and trembling Tom. But you are not sure if one of them really fit to Violet, so you gave them a questionnaire about their hobbies because you believe that Violet needs someone to interact with.

And here are the results in a data frame, of course Violet did the same questionnaire:

Olaf <- c(1,0,1,1,1,1,0)
Sven <- c(1,1,1,0,0,0,0)
Violet <- c(0,1,0,0,1,1,1)
Tom  <- c(1,0,0,1,0,0,0)

people <-as.data.frame( cbind(Olaf,Sven,Violet,Tom))
rownames(people) <-  c("sex", "rugby","basketball","badminton","soccer","lovestats","lovesR")

people
##            Olaf Sven Violet Tom
## sex           1    1      0   1
## rugby         0    1      1   0
## basketball    1    1      0   0
## badminton     1    0      0   1
## soccer        1    0      1   0
## lovestats     1    0      1   0
## lovesR        0    0      1   0

So that looks pretty nice, but how could we easily find out who has the biggest intersection with vivid Violet?

We can use an Upset diagram from the UpSetR package on Github (also available on Cran) and plot our findings:

library(devtools)
devtools::install_github("hms-dbmi/UpSetR")
library(UpSetR)
upset(people, sets = c("Olaf","Sven","Violet","Tom"),order.matrix = "freq",sets.bar.color="red",matrix.color = "blue")

Violet has an own intersection because she is the only one who loves R, a feeling that every R nerd can sympathize.

It seems that Olaf and Violet have the most in commmon, because they both like soccer and statistics. That’s pretty nice.

The UpSetR plot above seems a little bit tricky by the first view, but it is nothing else as a Venn Diagram. But even with just four people it is really hard to interpret a normal Venn Diagram like this:

library(gplots)
venn(people)

So UpSetR shows us with one look who of these people have the most intersection.

As we can see, old Olaf is the best Partner for vivid Violet! So they can marry immidiately, get children and become old together… R has predicted it and so it will … no it must … be true!

If you are interested in UpSet visit the official Page or the UpSetR Github Page