I have multiple columns of data, let's say x and time. I want to make a histogram of column x, and color each bar based off an aggregation of the values in column time, where the aggregation is grouped by the breaks used for the histogram. So,
d = cbind(c(rep(1,3), rep(2,3)), c(10,20,10,20,10,20))
names(d) = c("x", "time")
hist(d[,"x"])
Gives me a nice barplot, and let's say I want something like this for my colors:
palette(rainbow(25))
hist(d[,"x"], col=d[,"time"], n=10)
I would like to have the col be a vector of length 10 that is an aggregated function (such as mean) of the time column.