Skip to content

Instantly share code, notes, and snippets.

View mbannert's full-sized avatar

Matt Bannert mbannert

View GitHub Profile
\documentclass{article}
\begin{document}
<<regression,results='asis'>>=
library(texreg)
data(mtcars)
fit1 <- lm(mpg~wt+disp,data=mtcars)
texreg(fit1)
@mbannert
mbannert / benchmark.R
Last active December 15, 2016 09:41
jsonlite vs rjsonion - can we make jsonlite faster?
library(microbenchmark)
# json test is a character vector of length 2 containing
# both of the json elements given in sample_data.json
microbenchmark(
lite <- lapply(json_test,function(x){
jsonlite::fromJSON(x,simplifyVector = F)
}),
SONIO <- lapply(json_test,function(x){
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 / read geo file
Created April 21, 2016 08:29
PostgreSQL Postgis R GeoJSON example
# Postgis data type in my case is WSG84: geom | geometry(Point,4326)
library(jsonlite)
library(RPostgreSQL)
source("dbConnect.R") # create some connection object called con
p <- dbGetQuery(con,
"SELECT id,
postal_code,
st_asGeoJSON(geom)
FROM sometable
@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
@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 / 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 / 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 / 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 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>