title: Color interpolation in R when dataset has NA values
body: <p>I am trying to interpolate a color palette based on the values of the variable "weight" of my dataset.</p>
  
  <pre><code>F2 &lt;- colorRampPalette(c("#c2c6b3", "#353828"), bias = length(unique(E(gD)$weight)), space = "rgb", interpolate = "linear")
  </code></pre>
  
  <p>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.</p>
  
  <p>As a result, when I try to assign the colors generated from this function into the edges of my network graph in R, </p>
  
  <pre><code>colCodes &lt;- F2(length(unique(E(gD)$weight2)))
  edges_col &lt;- sapply(E(gD)$weight2, function(x)
  colCodes[which(sort(unique(E(gD)$weight2)) == x)])`
  edges_col_df &lt;- as.data.frame(t(col2rgb(edges_col, alpha = FALSE)))
  </code></pre>
  
  <p>I get the error: "invalide color name `character(0)'"</p>
  
  <p>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 <a href="https://stackoverflow.com/questions/30130487/imputing-missing-values-keeping-circular-trend-in-mind/30131676#30131676">Imputing missing values keeping circular trend in mind</a> 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.</p>