Created
August 22, 2016 02:32
-
-
Save gluc/4e27a90904c68c8bbbe3ae2e00e6f2eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(data.tree) | |
yaml <- " | |
campus: | |
south: | |
label: campussouth | |
north: | |
label: campusnorth | |
" | |
lol <- yaml::yaml.load(yaml) | |
tree <- as.Node(lol) | |
# dummy data | |
df <- data.frame(campussouth = 1, campusnorth = 1:10) | |
# assign data to tree Nodes | |
for (leaf in tree$leaves) { | |
leaf$data <- df[leaf$label] | |
} | |
#check if data is on the leaf | |
tree$campus$south$data | |
#do crazy analytics | |
tree$Do(function(node) { | |
if (node$isLeaf) node$max <- max(node$data) | |
else node$max <- Aggregate(node, "max", max) | |
} | |
) | |
print(tree, "max") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment