Problem with Topic correlation steps (Error in rgb(color))

When I enter the following code

net2 <- simplify(net2, remove.multiple = F, remove.loops = T)

links <- as_data_frame(net2, what="edges")
nodes <- as_data_frame(net2, what="vertices")

Community Detection

clp <- cluster_label_prop(net2)
nodes$community <- clp$membership

means <- as.data.frame(unlist(STMresults$means))
colnames(means) <- "means"
color <- colorRamp(c("white","blue"))(abs(means$means)/0.05)
means$colorDem <- rgb(color[,1],color[,2],color[,3], maxColorValue=255)

color <- colorRamp(c("white","red"))(abs(means$means)/0.05)
means$colorRep <- rgb(color[,1],color[,2],color[,3], maxColorValue=255)

means$color <- ifelse(means$means>0,means$colorDem,means$colorRep)

#visNetwork edits
nodes$shape <- "dot"
nodes$shadow <- TRUE # Nodes will drop shadow
nodes$title <- apply(topicNames$prob, 1, function(x) paste0(x, collapse = " + "))[rank] # Text on click
nodes$label <- topic$topicnames # Node label
nodes$size <- (topic$TopicProportions / max(topic$TopicProportions)) * 40 # Node size
nodes$borderWidth <- 2 # Node border width

nodes$color.background <- means$color
nodes$color.border <- "black"
nodes$color.highlight.background <- "orange"
nodes$color.highlight.border <- "darkred"
nodes$id <- topic$TopicNumber

I am getting this error

Error in rgb(color[, 1], color[, 1], color[, 1], maxColorValue = 1) :
color intensity NA, not in [0,1]

I am new to R and I am correctly following the tutorial. So far I managed to solve other steps and this is the last step and I can't comprehend where I am going wrong. Please help me to figure out the issue, thank you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.