Skip to content

Instantly share code, notes, and snippets.

View mbannert's full-sized avatar

Matt Bannert mbannert

View GitHub Profile
@mbannert
mbannert / server.r
Created December 5, 2012 10:33 — forked from wch/server.r
Shiny example: dynamic input fields
# Some pre-computed stuff in R. In this example, just assign values to a var
data_sets <- c("mtcars", "morley", "rock")
shinyServer(function(input, output) {
# Drop-down selection box for which data set
output$choose_dataset <- reactiveUI(function() {
selectInput("dataset", "Data set", as.list(data_sets))
})
@mbannert
mbannert / index.html
Created November 12, 2013 19:47
Stan
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://nvd3.org/src/nv.d3.css'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' type='text/javascript'></script>
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script>
<script src='http://nvd3.org/nv.d3.js' type='text/javascript'></script>
<script src='http://nvd3.org/lib/fisheye.js' type='text/javascript'></script>
@mbannert
mbannert / index.html
Created November 12, 2013 20:12
Stan
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://nvd3.org/src/nv.d3.css'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' type='text/javascript'></script>
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script>
<script src='http://nvd3.org/nv.d3.js' type='text/javascript'></script>
<script src='http://nvd3.org/lib/fisheye.js' type='text/javascript'></script>
@mbannert
mbannert / index.html
Created November 12, 2013 21:41
Stan
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.oesmith.co.uk/morris-0.4.2.min.css'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js' type='text/javascript'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js' type='text/javascript'></script>
<script src='http://cdn.oesmith.co.uk/morris-0.4.2.min.js' type='text/javascript'></script>
@mbannert
mbannert / calc_shares.R
Created December 11, 2013 14:57
better documentation of calcShares
# This file documents calcshares using the oxygen documentation standard
# google for roxygen
# you don't need to source this file, it's just for documentation
# puporses.
#' Calculate the weighted share of an answer item
#'
#' This function calculates how often an answer item was selected relatively
#' to the other answer item of a question. The result is given as a share.
#' Besides the function calculates additional information that is described
@mbannert
mbannert / flare.json
Created December 14, 2013 22:13 — forked from mbostock/.block
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "size": 3938},
@mbannert
mbannert / problem_description
Last active January 3, 2016 03:39
discussing a possible devtools issue with @hadley
# I am not sure whether this is a) misunderstanding of the SO answer
(http://stackoverflow.com/questions/17662713/devtools-description-file),
b) a roxygen c) or rstudio or d) devtools issue.
# Started out a new package using create("newpackage") from devtools. I get a description file like this:
# start of file ####
Package: newpackage
Title:
Description:
Version: 0.1
df1 <- data.frame(a=c(1,2,3),
b=c(3,2,1),
d=c(4,5,4))
df1[with(df1,a+b == d),]
data_sets <- c("mtcars")
shinyServer(function(input, output) {
# Drop-down selection box for which data set
output$choose_dataset <- renderUI({
selectInput("dataset", "Data set", as.list(data_sets))
})
# select a car
@mbannert
mbannert / indexing_example.R
Created May 20, 2014 11:10
Example for Pauliina
test <- list()
test[[1]] <- cor(matrix(rnorm(20),ncol=4))
test[[2]] <- cor(matrix(rnorm(20),ncol=4))
test[[3]] <- cor(matrix(rnorm(20),ncol=4))
# should be 1: element 1,1