r <- rast(ncols=3, nrows=2, vals=0:5)
coltb <- data.frame(t(col2rgb(rainbow(6, end=.9), alpha=TRUE)))
coltb
plot(r)
has.colors(r)
coltab(r) <- coltb
plot(r)
has.colors(r)
tb <- coltab(r)
class(tb)
dim(tb[[1]])
Run the code above in your browser using DataLab