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
--- | |
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
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
#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
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
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) | |
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(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(data.tree) | |
library(xts) | |
f <- read.csv("https://gist.githubusercontent.com/gluc/3969bcfb2ddce61d8bdec2f52c133674/raw/16b577a6842492153db8e95ede0062a6187e60ab/hts-data.csv", stringsAsFactors = FALSE) | |
# construct tree | |
# ============== | |
# you may chose a different hierarchy order | |
dfs <- data.frame(pathString = paste("rt", df$u_loc, df$u_code, df$c_code, df$citizenship, df$grade, sep = "/"), stringsAsFactors = FALSE) |
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
nodes <- structure(list(id = 1:11, style = c("", "", "", "", "", "", "", | |
"", "", "", ""), shape = c("", "", "egg", "egg", "", "egg", "egg", | |
"", "egg", "egg", "egg"), fillcolor = c("", "Thistle", "", "", | |
"", "", "", "LightBlue", "LightBlue", "LightBlue", "LightBlue" | |
), fontname = c("", "", "", "", "", "", "", "", "", "", ""), | |
tooltip = c("- name: Acme Inc.", "This is the accounting department", | |
"- cost: 1e+06\n- p: 0.5", "- cost: 5e+05\n- p: 0.75", "- name: Research", | |
"- cost: 2e+06\n- p: 0.25", "- cost: 750000\n- p: 0.9", "- name: IT", | |
"- cost: 4e+05\n- p: 0.2", "- cost: 250000\n- p: 0.05", "- cost: 50000\n- p: 1" | |
), fontcolor = c("", "Firebrick", "", "", "", "", "", "", |