i trying interpolate color palette based on values of variable "weight" of dataset.
f2 <- colorramppalette(c("#c2c6b3", "#353828"), bias = length(unique(e(gd)$weight)), space = "rgb", interpolate = "linear") however, values on dataset have na values, , provoques (0) value on color generated edge on network graph.
as result, when try assign colors generated function edges of 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 error: "invalide color name `character(0)'"
i saw on different post how extrapolate on case of missing values median o mean of values around missing observation imputing missing values keeping circular trend in mind in case, observations na values acquire value of lower limit of range of colors.
one possible solution recode na values corresponding lower limit value.
data$variable[is.na(data$variable)]<-min(data$variable) sometimes make vector new variable data integrity reasons.
data$variable2[is.na(data$variable)]<-min(data$variable) hope helps!
Comments
Post a Comment