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 | |
" |
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(yaml) | |
library(data.tree) | |
yaml <- " | |
functions: | |
currbalfun: | | |
function(node) { | |
Aggregate(deal, 'currbal', function(bal) sum(bal, na.rm = TRUE)) | |
} | |
TC_1: |
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) | |
library(yaml) | |
yaml <- " | |
node1: | |
value: 2 | |
fnct: > | |
function(x) { | |
2 * x |
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
#How to plot data.tree to PDF? | |
#This was tested with data.tree 0.3.6 | |
#Various options | |
library(data.tree) | |
data(acme) | |
# 1. ape package | |
library(ape) |
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
tmp <- tempfile(fileext = ".log") | |
x <- runif(10e5) | |
f <- function(x) c(mean(x), median(x), sd(x)) | |
f2 <- function(x) { | |
c(sum(x) / length(x), | |
median.default(x), | |
sqrt(sum((x - sum(x) / length(x))^2L) / (length(x) - 1L))) | |
} | |
Rprof(tmp, interval = 0.01) |
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
--- | |
title: "Untitled" | |
author: "cg" | |
date: "Monday, October 19, 2015" | |
output: html_document | |
--- | |
```{r} |
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
#CRUD for multiple tables | |
library(shiny) | |
library(shinyjs) | |
# Get table metadata. For now, just the fields | |
# Further development: also define field types | |
# and create inputs generically | |
GetTableMetadata <- function() { |
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
#requires data.tree 0.2.2 | |
library(data.tree) | |
library(yaml) | |
library(stringr) | |
fileName <- 'jennylind.yaml' | |
l <- yaml.load_file(fileName) | |
jl <- as.Node(l) | |
#this file contains all the functions referred to from the yaml |
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) | |
CreateCrossoverRandomTree <- function(n, treeId) { | |
tree <- CreateRandomTree(n) | |
tree$Set(treeId = treeId) | |
tree$Set(id = 1:tree$totalCount) | |
return (tree) | |
} | |
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(shiny) | |
library(shinyjs) | |
# Get table metadata. For now, just the fields | |
# Further development: also define field types | |
# and create inputs generically | |
GetTableMetadata <- function() { | |
fields <- c(id = "Id", |