I am trying to order a heat map in geom_tile()
x <- structure(list(id = c("1", "1", "1", "2", "2", "3", "3", "3"),
time = c("1", "2", "3", "1", "3", "1", "2", "3"),
response = c( "0", "1", "1", "1", "1", "0", "0", "1")),
.Names = c("id", "time", "response"), class = "data.frame")
df %>%
ggplot() + geom_tile(aes(time, id, fill=response))
id is numeric and time and response are factors. My heat map should have id on the y-axis and time on the x-axis. I'm trying to group sets of responses so that each line is an id but that id's who follow the same pattern of 0,0,0 for the time periods are grouped together in blocks. I've tried order, reorder, and scale_y_continuous, but none of them change the order of responses.
This answer comes close to what I'm looking for, but none of the answers seem to work.