For all examples the movies data set contained in the package will be used.

library(UpSetR)
movies <- read.csv(system.file("extdata", "movies.csv", package = "UpSetR"), 
    header = T, sep = ";")


set.metadata Parameter Breakdown

The set.metadata parameter is broken up into 3 fields: data, ncols, and plots.

Example 1: Set Metadata Bar Plot

In this example, the average Rotten Tomatoes movie ratings for each set will be used as the set metadata. This may help us draw more conclusions from the visualization by knowing how professional movie reviewers typically rate movies in these categories.

sets <- names(movies[3:19])
avgRottenTomatoesScore <- round(runif(17, min = 0, max = 90))
metadata <- as.data.frame(cbind(sets, avgRottenTomatoesScore))
names(metadata) <- c("sets", "avgRottenTomatoesScore")

When generating a bar plot using set metadata information it is important to make sure the specified column is numeric.

is.numeric(metadata$avgRottenTomatoesScore)
## [1] FALSE

The column is not numeric! In fact it is a factor, so we must coerce it to characters and then to integers.

metadata$avgRottenTomatoesScore <- as.numeric(as.character(metadata$avgRottenTomatoesScore))
upset(movies, set.metadata = list(data = metadata, plots = list(list(type = "hist", 
    column = "avgRottenTomatoesScore", assign = 20))))

Example 2: Set Metadata Heat Map

In this example we will make our own data on what major cities these genres were most popular in. Since this is categorical and not ordinal we must remember to change the column to characters (it is a factor again). To make sure we assign specific colors to each category you can specify the name of each category in the color vector, as shown below. If you don’t care what color is assigned to each category then you don’t have to specify the category names in the color vector. R will just apply the colors to each category in the order they occur. Additionally, if you don’t supply anything for the colors parameter a default color palette will be provided for you.

Cities <- sample(c("Boston", "NYC", "LA"), 17, replace = T)
metadata <- cbind(metadata, Cities)
metadata$Cities <- as.character(metadata$Cities)
metadata[which(metadata$sets %in% c("Drama", "Comedy", "Action", "Thriller", 
    "Romance")), ]
##        sets avgRottenTomatoesScore Cities
## 1    Action                     30     LA
## 4    Comedy                     76    NYC
## 7     Drama                     50 Boston
## 13  Romance                      6    NYC
## 15 Thriller                     46 Boston
upset(movies, set.metadata = list(data = metadata, plots = list(list(type = "heat", 
    column = "Cities", assign = 10, colors = c(Boston = "green", NYC = "navy", 
        LA = "purple")))))

Now lets also use our numeric critic values!

upset(movies, set.metadata = list(data = metadata, plots = list(list(type = "heat", 
    column = "Cities", assign = 10, colors = c(Boston = "green", NYC = "navy", 
        LA = "purple")), list(type = "heat", column = "avgRottenTomatoesScore", 
    assign = 10))))