I am trying to interpolate a color palette based on the values of the variable "weight" of my dataset.
F2 <- colorRampPalette(c("#c2c6b3", "#353828"), bias = length(unique(E(gD)$weight)), space = "rgb", interpolate = "linear")
However, some values on my dataset have NA values, and this provoques a (0) value on the color generated for that edge on my network graph.
As a result, when I try to assign the colors generated from this function into the edges of my network graph in R,
colCodes <- F2(length(unique(E(gD)$weight2)))
edges_col <- sapply(E(gD)$weight2, function(x)
colCodes[which(sort(unique(E(gD)$weight2)) == x)])`
edges_col_df <- as.data.frame(t(col2rgb(edges_col, alpha = FALSE)))
I get the error: "invalide color name `character(0)'"
I saw on a different post how to extrapolate on the case of missing values by the median o mean of values around the missing observation Imputing missing values keeping circular trend in mind but in my case, I would like the observations with NA values to acquire the value of the lower limit of my range of colors.