I have the following data.table:
require(data.table)
require(ggplot2)
set.seed(1234)
dt = data.table(id = paste0('ID_', 1:2000),
group = rep(LETTERS[1:5], 400),
value = as.logical(rbinom(2000, 1, prob = 0.25)))
I would like to create a ggplot like below, where on the y-axis only the text labels, for which the variable value equals TRUE are drawn, without removing the other data. Additionally, it would be best, if the text labels won't overlap (if possible), hence using all the empty y-axis space.
# draws all categorical id values
ggplot(dt, aes(y = reorder(id, -value), x = group, fill = value)) +
geom_tile() +
theme_bw()
