Skip to content

Instantly share code, notes, and snippets.

@reinholdsson
reinholdsson / gist:7271120
Last active December 27, 2015 04:59
R ReferenceClasses: dynamically create methods and overload tab autocomplete
# Variables to loop
vars <- c("var1", "var2")
# Generate a list of functions (specific for each variable)
var_methods <- lapply(vars, function(i){
fun <- function(var = i) paste("This is", var)
formals(fun)$var <- i
return(fun)
})
names(var_methods) <- vars
@reinholdsson
reinholdsson / README.md
Created September 9, 2013 08:45 — forked from mbostock/.block

This bar chart visualizes hierarchical data using D3. Each blue bar represents a folder, whose length encodes the total size of all files in that folder (and all subfolders). Clicking on a bar dives into that folder, while clicking on the background bubbles back up to the parent folder. The effect is similar to a zoomable partition layout, though in a more conventional display.

@reinholdsson
reinholdsson / README.md
Created August 25, 2013 09:38
Chart comments shiny app
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/modules/exporting.js' type='text/javascript'></script>
cData <- read.table(textConnection("
no Grade Count
1 01 40272
2 02 36902
3 03 1288
4 04 992
5 05 517
6 K 334
7 KA 8236
8 KP 6704"), sep = '', header = T

metagraf

Prisbasbelopp

Data för de olika indexen har hämtats från SCB:s API för Statistikdatabasen. Utifrån dessa har sedan de alternativa prisbasbeloppen beräknats.

metagraf

Prisbasbelopp

Data för de olika indexen har hämtats från SCB:s API för Statistikdatabasen. Utifrån dessa har sedan de alternativa prisbasbeloppen beräknats.

<!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>
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://dimplejs.org/dist/dimple.v1.min.js' type='text/javascript'></script>
<style>
.rChart {
<!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>