我一直在查看data.tree
软件包的手册,但是一旦创建了data.tree
结构,我就无法找到保存a.onclick = this.showLightbox;
结构的方法。有没有办法编写data.tree结构而不是将其转换为另一个结构(即data.frame)然后保存它?
答案 0 :(得分:1)
你的问题有点模糊,因为我不知道你指的是什么类型的对象。但是,这似乎对我有用。
.
└── node_modules
├── my-software
│ ├── bin.js
│ ├── package.json
│ └── src
├── some-required-module
│ ├── HISTORY.md
│ ├── index.js
│ ├── LICENSE
│ ├── package.json
│ └── README.md
答案 1 :(得分:1)
data(acme)
print(acme)
acme$fieldsAll
acme$count
acme$totalCount
acme$isRoot
acme$height
print(acme, "p", "cost")
outsource <- acme$IT$Outsource
class(outsource)
print(outsource)
outsource$fields
outsource$isLeaf
outsource$level
outsource$path
outsource$p
outsource$parent$name
outsource$root$name
outsource$expCost <- outsource$p * outsource$cost
print(acme, "expCost")
acme$Get("p")
acme$Do(function(x) x$expCost <- x$p * x$cost)
acme$Get("expCost", filterFun = isLeaf)
ToDataFrameTable(acme, "name", "p", "cost", "level", "pathString")
ToDataFrameTree(acme, "name", "p", "cost", "level")
ToDataFrameNetwork(acme, "p", "cost")
tree <- ToDataFrameTree(acme, "name", "p", "cost", "level")
saveRDS(tree, "tree.RDS")
it_works <- readRDS("tree.RDS")
it_works
levelName name p cost level 1 Acme Inc. Acme Inc. NA NA 1 2 ¦--Accounting Accounting NA NA 2 3 ¦ ¦--New Software New Software 0.50 1000000 3 4 ¦ °--New Accounting Standards New Accounting Standards 0.75 500000 3 5 ¦--Research Research NA NA 2 6 ¦ ¦--New Product Line New Product Line 0.25 2000000 3 7 ¦ °--New Labs New Labs 0.90 750000 3 8 °--IT IT NA NA 2 9 ¦--Outsource Outsource 0.20 400000 3 10 ¦--Go agile Go agile 0.05 250000 3 11 °--Switch to R Switch to R 1.00 50000 3 >
答案 2 :(得分:1)
这是一个相关问题的答案:如何将data.tree保存到另一个对象?
这非常重要,因为有几种方法会改变原始data.tree,这是我遇到的一个问题。
# What one would expect
myDataTree_clone <- myDataTree
如果你改变了这个“克隆”,你实际上也改变了myDataTree对象。
# What one should do instead
myDataTree_clone <- Clone(myDataTree)
现在,您可以在不更改原始myDataTree对象的情况下使用克隆。