For example, I have this alpha function in
ggplot:
alpha <- function(colour, alpha) {
col <- col2rgb(colour, TRUE) / 255
col[4, ] <- rep(alpha, length(colour))
new_col <- rgb(col[1,], col[2,], col[3,], col[4,])
new_col[is.na(colour)] <- NA
new_col
}
which seems like a lot of work for a simple task. The fact that
col2rgb and rgb aren't symmetric is frustrating, especially since one
outputs values between 0 and 255 and the other (by default) accepts
inputs between 0 and 1.
Package 'vcd' (and others) use package 'colorspace',
and I have wondered in the past if these color space computations
should not be merged into to standard R (package 'grDevices').
But that's really a topic for another thread, on R-devel, not R-help..
It would definitely be nice if all colour space manipulations were
merged into a single package, with a consistent interface. I would
happily contribute to such a project, since I do a lot of colour
manipulation in ggplot.
Hadley