hive图中自边的r误差

slhcrj9b  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(428)

即使没有自边缘,也绝对无法理解错误的原因。
下面是一个可复制的代码。任何帮助都会很好

library(HiveR)

nodes = data.frame(id = 1:9, lab = c("A","B","C","E","F","G","H","I","J"), 
axis = c(1,1,1,2,3,2,2,2,3), radius = rep(50,9),size = rep(10,9),
color = c("yellow","yellow","yellow", "green","red","green","green","green","red"))

edges = data.frame(id1 = c(1,2,3,4,5,4,1,9,8,6,1),id2 = c(2,3,4,1,9,9,9,8,7,7,6), 
weight = rep(1,11),
color = c(rep("green",7), rep("red",4)))
        test3 <- ranHiveData(nx = 3)
        test3$nodes = nodes
        test3$edges = edges
        test3$edges$color <- as.character(test3$edges$color)
        test3$edges$id1 <- as.integer(test3$edges$id1)
        test3$edges$id2 <- as.integer(test3$edges$id2)
        test3$nodes$color <- as.character(test3$nodes$color)
        test3$nodes$lab <- as.character(test3$nodes$lab)
        test3$nodes$axis = as.integer(test3$nodes$axis)
        test3$nodes$id = as.integer(test3$nodes$id)
        test3$nodes$radius = as.numeric(test3$nodes$radius)
        test3$nodes$size = as.numeric(test3$nodes$size)
        test3$edges$weight = as.numeric(test3$edges$weight)
        test3$desc = "3 axes --9 nodes -- 11 edges"
        sumHPD(test3, chk.sm.pt = TRUE)

代码给出了自边,而绘图没有呈现plothive(test3)显示的结果
calccurvegrob(x,x$debug)中出错:端点不能相同

t1qtbnec

t1qtbnec1#

在代码中,轴节点的位置( radius )都设置为50。
因此存在重叠点(轴1上有3个,轴2上有4个,轴3上有2个)。
正确定义 radius 解决问题。

library(HiveR)

# radius has been changed !

nodes = data.frame(id = 1:9, lab = c("A","B","C","E","F","G","H","I","J"), 
axis = c(1,1,1,2,3,2,2,2,3), radius = c(1,2,3,1,1,2,3,4,2),size = rep(1,9),
color = c("yellow","yellow","yellow", "green","red","green","green","green","red"))

edges = data.frame(id1 = c(1,2,3,4,5,4,1,9,8,6,1),id2 = c(2,3,4,1,9,9,9,8,7,7,6), 
weight = rep(1,11),
color = c(rep("green",7), rep("red",4)))
        test3 <- ranHiveData(nx = 3)
        test3$nodes = nodes
        test3$edges = edges
        test3$edges$color <- as.character(test3$edges$color)
        test3$edges$id1 <- as.integer(test3$edges$id1)
        test3$edges$id2 <- as.integer(test3$edges$id2)
        test3$nodes$color <- as.character(test3$nodes$color)
        test3$nodes$lab <- as.character(test3$nodes$lab)
        test3$nodes$axis = as.integer(test3$nodes$axis)
        test3$nodes$id = as.integer(test3$nodes$id)
        test3$nodes$radius = as.numeric(test3$nodes$radius)
        test3$nodes$size = as.numeric(test3$nodes$size)
        test3$edges$weight = as.numeric(test3$edges$weight)
        test3$desc = "3 axes --9 nodes -- 11 edges"
        sumHPD(test3, chk.sm.pt = TRUE)

plotHive(test3)

相关问题