How can I use eulerr (venn-like diagram in R) with a matrix of logicals within PowerBI?

47 views Asked by At

I'm using the R extension of PowerBI, and I successfully created a eulerr diagram using a series of named numeric vectors that I defined using a ton of powerBI measures:

library(eulerr)
diagram <- euler(c("Higher Ed"=dataset$"H only",Academic = dataset$"A only",  Industrial = dataset$"I only", Vocational = dataset$"V only","Academic&Vocational"=dataset$"AV only",
                     "Academic&Higher Ed" = dataset$"AH only", "Higher Ed&Industrial" = dataset$"HI only", "Higher Ed&Vocational" = dataset$"HV only","Academic&Industrial"=dataset$"IA only",
                     "Industrial&Vocational" = dataset$"IV only", "Higher Ed&Industrial&Vocational" = dataset$"HIV only", "Higher Ed&Academic&Vocational"=dataset$"HAV only",
                     "Higher Ed&Academic&Industrial"=dataset$"HAI only", "Academic&Vocational&Industrial"= dataset$"AVI only", "Higher Ed&Academic&Vocational&Industrial"=dataset$"HAVI"
                    ),
                   shape = "ellipse")
plot(diagram,quantities=TRUE, edges = list(lty = 2))

It is cumbersome to set up all these calculations, and I'd like to use the "matrix of logicals" feature of eulerr to do the heavy lifting instead. It should look something like this:

library(eulerr)
diagram <- euler(dataset)
plot(diagram,quantities=TRUE, edges = list(lty = 2))

This method displays a Euler diagram with the value of '1' in each of the slices. I think it has to do with the way powerbi filters the dataset to unique values.

I have tried to separate the data frame into vectors and recombine them, but I'm such a noob to R that I'm not sure what I'm doing. I think my data is already set up as a logical matrix: four variables (Academic, Higher Ed, Industrial, Vocational) with 1 or 0 in the variable for each row. I can include a fifth variable for a unique record number, but I don't know how to use it in the matrix formatted for Eulerr.

0

There are 0 answers