Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的基本分层边绑定_R_Connection_Hierarchical Data - Fatal编程技术网

R中的基本分层边绑定

R中的基本分层边绑定,r,connection,hierarchical-data,R,Connection,Hierarchical Data,这可能是一个非常基本的问题,但我正在创建一个层次化的边缘绑定,当我可视化连接时,图形并没有水平显示,它似乎在原始节点中显示了一个连接,它不应该在那里 代码如下: # create a data frame giving the hierarchical structure of your data. d1 <- data.frame(from="origin", to=c("Questionnaires", "Cognitive&

这可能是一个非常基本的问题,但我正在创建一个层次化的边缘绑定,当我可视化连接时,图形并没有水平显示,它似乎在原始节点中显示了一个连接,它不应该在那里

代码如下:

# create a data frame giving the hierarchical structure of your data.     
d1 <- data.frame(from="origin", to=c("Questionnaires", "Cognitive","Momentary Fatigue","Subjective","Behavioural","Pupillometry","fNIRS"))    
d2 <- data.frame(from="Questionnaires", to=c("EAS","FAS","HHQ","SSQ12"))    
d3 <- data.frame(from="Cognitive", to=c("TRT","RSpan"))    
d4 <- data.frame(from="Momentary Fatigue", to=c("Pre","Post"))    
d5 <- data.frame(from="Subjective", to=c("Av_EF","Slope_EF","Av_IN","Slope_IN","Av_TA","Slope_TA"))    
d6 <- data.frame(from="Behavioural", to=c("Av_PC","Slope_PC","Av_RT","Slope_RT","Av_LE","Slope_LE"))    
d7 <- data.frame(from="Pupillometry", to=c("Av_MPD","Slope_MPD","Av_PPD","Slope_PPD","Av_BL","Slope_BL","Av_SL","Slope_SL"))    
d8 <- data.frame(from="fNIRS", to=c("Av_LSTG","Slope_LSTG","Av_RSTG","Slope_RSTG","Av_LIFG","Slope_LIFG","Av_RDLPFC","Slope_RDLPFC","Av_FP","Slope_FP"))    
hierarchy <- rbind(d1, d2,d3,d4,d5,d6,d7,d8)


vertices <- data.frame(name = unique(c(as.character(hierarchy$from), as.character(hierarchy$to))))    
vertices$group  <-  hierarchy$from[match(vertices$name,hierarchy$to)]

from <- match(connect$from, vert$name)    
to <- match(connect$to, vert$name)

# Create a graph object
mygraph <- graph_from_data_frame(hierarchy,vertices=vert)
ggraph(mygraph, layout = 'dendrogram', circular = TRUE) + 
  geom_conn_bundle(data = get_con(from = from, to = to), alpha=0.2, colour="skyblue", tension = .5) + 
  geom_node_point(aes(filter = leaf, x = x*1.05, y=y*1.05)) +
  theme_void()
#创建一个数据框,给出数据的层次结构。
d1