2017-06-20 2 views
0

パッケージドキュメント?FromDataFrameNetworkこれは(親から子どもへ)登山のいずれかになります方向を指定する方法Rのdata.treeパッケージ:(子の親、あるいは他の方法で)方向を指定する方法

を語りますまたは降順 (子から親へ)

Q1。なぜdirection = "descen"は動作しません:

library(data.tree) 
data(acme) 

x = ToDataFrameNetwork(acme, direction = "climb") 
head(x) 
# from      to 
# 1 Acme Inc.    Accounting 
# 2 Acme Inc.     Research 
# 3 Acme Inc.      IT 
# 4 Accounting    New Software 
# 5 Accounting New Accounting Standards 
# 6 Research   New Product Line 

x = ToDataFrameNetwork(acme, direction = "descen") 
# Error in ToDataFrameNetwork(acme, direction = "descen") : 
#   direction descen unknown. Must be either climb or descen. 

#of course i can manually make it from child to parent: 
x_the_other_way = x[ , c('to', 'from')] 
head(x_the_other_way) 
#      to  from 
# 1    Accounting Acme Inc. 
# 2     Research Acme Inc. 
# 3      IT Acme Inc. 
# 4    New Software Accounting 
# 5 New Accounting Standards Accounting 
# 6   New Product Line Research 

Q2。データフレームネットワークをツリーに変換するときの方向を指定する方法は?

xN <- FromDataFrameNetwork(x, direction = "climb") 
# Error in FromDataFrameNetwork(x, direction = "climb") : 
#   unused argument (direction = "climb") 

Q2についての更新:アルゴリズムは方向を把握します。ユーザーは指定する必要はありません。私はそれがに基づいてそれを把握することが推測「だけつのルートがあります」

xN = FromDataFrameNetwork(x) 
xN_the_other_way = FromDataFrameNetwork(x_the_other_way) 

xN 
# levelName 
# 1 Acme Inc.      
# 2 ¦--Accounting     
# 3 ¦ ¦--New Software    
# 4 ¦ °--New Accounting Standards 
# 5 ¦--Research      
# 6 ¦ ¦--New Product Line   
# 7 ¦ °--New Labs     
# 8 °--IT       
# 9  ¦--Outsource    
# 10  ¦--Go agile     
# 11  °--Switch to R 

xN_the_other_way 
# levelName 
# 1 Acme Inc.      
# 2 ¦--Accounting     
# 3 ¦ ¦--New Software    
# 4 ¦ °--New Accounting Standards 
# 5 ¦--Research      
# 6 ¦ ¦--New Product Line   
# 7 ¦ °--New Labs     
# 8 °--IT       
# 9  ¦--Outsource    
# 10  ¦--Go agile     
# 11  °--Switch to R 

感謝you-が

答えて

1

ToDataFrameNetworkのヘルプは言う:

?ToDataFrameNetwork 
direction when converting to a network, should the edges point from root to children ("climb") or from child to parent ("descend")? 

だから、あなたが指定しなければならないのいずれかclimbまたはdescend

(エラーメッセージに誤字があります。既にgithubに修正されていますが、まだCRANでは修正されていません)。

2番目の質問について:はい、最初の2つの列に表示されるネットワークはツリーである必要があります。つまり、ルートは1つだけです。したがって、アルゴリズムがどの方向のネットワークが指定されているかを知ることは簡単です。

関連する問題