[R] attribute color to a list

Karim Mezhoud kmezhoud at gmail.com
Fri Aug 28 12:16:48 CEST 2015


Hi,
attriColorValue works with one value. I would like to get the color of a
list with lappy but in input I have two variables (the value and the list).


attriColorValue <- function(Value, list, colors=c(a,b,c, d,e),feet){

     list <- round(list, digits = 0)
    Max <- max(list, na.rm=TRUE)
    Min <- min(list, na.rm=TRUE)

  my.colors <- colorRampPalette(colors)
  #generates Max-Min colors from the color ramp
  color.df<-data.frame(COLOR_VALUE=seq(Min,Max,feet),
color.name=my.colors(length(seq(Min,Max,feet))))

  colorRef <- color.df[which(color.df[,1]==Value),2]
  return(colorRef)
}

list <-
c(7607.2149,36.0673,26.5613,-21.094,535.1462,8460.8617,3112.3839,1810.5521,-2783.7832,-1283.5496,879.4978,-307.8481,133.6729,51.6518,-212.3436,-118.6624,912.8616,16.7501,465.6139,486.3803,1051.6673,-1529.426,198.9787,-265.013,74.0492,-52.0192,-97.655,-5963.4183,-2118.4033,5701.5644,1987.7252,1638.274,1576.775,1520.7626,1039.4264,905.7974,-966.3739,365.2626,364.8378,258.3969,-323.999,-394.7463)

works
as.character(attriColorValue(123,list, colors=c("blue","white","red") ,
feet=1))

not working??
lapply(list, function(x) attriColorValue(x,df$exprsMeanDiff ,colors, feet))

Thanks
Karim

	[[alternative HTML version deleted]]



More information about the R-help mailing list