Skip to content

Instantly share code, notes, and snippets.

View prabhasp's full-sized avatar

Prabhas Pokharel prabhasp

View GitHub Profile
@prabhasp
prabhasp / PlotDKs.R
Created April 17, 2014 20:41
Plot the percent of don't know per question in two ossap surveys.
get_dk_reason <- function(df) {
dk <- names(df)[str_detect(names(df), "dont")]
llply(df[dk], function(x) { as.character(na.exclude(x)) })
}
plot_percent_dks <- function(dk_list, N) {
# d will be a list of question name and length
d <- ldply(dk_list, length)
# order the data frame
d <- arrange(d, V1)
# divide by N (which is supposed to be total responses
@prabhasp
prabhasp / index.Rmd
Last active August 29, 2015 14:00
Indicator Dependencies: R metaprogramming
<link href="http://kevinburke.bitbucket.org/markdowncss/markdown.css" rel="stylesheet">
Finding indicator dependencies
========================================================
I had been meaning to look into R's metaprogramming features for a while now. I finally had a chance today (thanks [Hadley](http://adv-r.had.co.nz/)!), and I used it to experiment towards a problem that had been in the back of my mind for a while: finding depencies within indicator definitions.
Below, I implement a find dependencies function, which takes a set of indicators, and finds dependencies within it. Indicators are fields within a dataset, some of which are already there, and some of which are newly created. The dependency finding problem is investigating which new indicators derive from which existing ones. We think of these relationships as dependencies: for an indicator such as pupil-to-teacher-ratio (defined as the number-of-pupils divided by the number-of-teachers), pupil-to-teacher-ratio is dependent on number-of-pupils
@prabhasp
prabhasp / headshot.jpg
Last active January 24, 2017 06:29
Re-color your images, Shepard Fairey-ish style
headshot.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<title>Foo</title>
<meta charset='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<style type='text/css'>
body {
background:#000;
color:#fff;

KTMJS Talk by @prabhasp

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />