Skip to content

Instantly share code, notes, and snippets.

@gluc
Created April 28, 2017 05:31
Show Gist options
  • Select an option

  • Save gluc/fac2bb5eeb9613cd376ccdf26ebbec86 to your computer and use it in GitHub Desktop.

Select an option

Save gluc/fac2bb5eeb9613cd376ccdf26ebbec86 to your computer and use it in GitHub Desktop.

Revisions

  1. gluc revised this gist Apr 28, 2017. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions trees.R
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ library(data.tree)
    data(acme)
    acme$Set(len = runif(acme$totalCount))


    # see ?as.data.frame.Node for more details
    ToDataFrameTree(acme,
    parent = function(node) node$parent$name,
    child = "name",
    @@ -11,5 +11,4 @@ ToDataFrameTree(acme,
    filterFun = isNotRoot)[,-1 ]

    #if you want to just display the difference:

    print(acme, "len", diff = function(node) node$len - ifelse(node$isRoot, 0, node$parent$len))
  2. gluc created this gist Apr 28, 2017.
    15 changes: 15 additions & 0 deletions trees.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    library(data.tree)
    data(acme)
    acme$Set(len = runif(acme$totalCount))


    ToDataFrameTree(acme,
    parent = function(node) node$parent$name,
    child = "name",
    len.parent = function(node) node$parent$len,
    len.child = "len",
    filterFun = isNotRoot)[,-1 ]

    #if you want to just display the difference:

    print(acme, "len", diff = function(node) node$len - ifelse(node$isRoot, 0, node$parent$len))