可折叠树示例无法正常工作

时间:2017-07-25 15:12:31

标签: r graph tree

我阅读了手册,并尝试重现以下示例。但是R会产生错误:

  

collapsibleTree中的错误(树,工具提示= TRUE,属性="值",aggFun =身份):df必须是数据框

我的问题是这段代码有什么问题。我使用的是R版本3.4.1。谢谢!

# Using a flat relationship-style data frame with tooltips
Relationships <- data.frame(
    Parent = c(".",".","A", "A", "A", "B", "B", "C", "E", "E", "F", "K", "K", "M", "M"),
    Child = c("A","K","B", "C", "D", "E", "F", "G", "H", "I", "J", "L", "M", "N", "O"),
    Value = 1:15
)

tree <- data.tree::FromDataFrameNetwork(Relationships, "Value")

# Define root node value as 0
tree$Value <- 0

# Create tree diagram with the aggregation function of identity
collapsibleTree(tree, tooltip=TRUE, attribute="Value", aggFun=identity)

1 个答案:

答案 0 :(得分:0)

我刚刚添加了需求并运行了您的代码,没有错误,如下所示:

var result = db.YourTable
   .FromSql("select * from your_table where array_length(devices) > 0")
   .Where(...)
   .OrderBy(...)
   ...
   .ToList();

结果如下:

enter image description here

这不是你所希望的吗?