I finally found a dirty solution
matrix <- as.data.frame(matrix(rexp(200, rate=.01), ncol=4))
Set the loop
for(i in 1:length(matrix[1,])) {
quant <- quantile(matrix[,i], prob = 0.85, na.rm = TRUE)
for(j in 1:length(matrix[,1])) {
if(as.numeric(matrix[j,i]) > quant) {
matrix[j,i] <- paste("\\cellcolor{red!25}", matrix[j,i], sep="", collapse = NULL)}
else {}
} } # close both loops
Then print the result in latex
print(xtable(matrix),
type = "latex",
sanitize.text.function = identity)
It give an acceptable result. It is important to set: "quant <- quantile" before the "j" loop. If not the change made during this "j" loop change matrix[,i] into a character vector and it is then impossible to re-compute the quantile.
Don't forget "sanitize.text.function = identity" in the print.