Skip to content

Instantly share code, notes, and snippets.

@aespar21
aespar21 / LinearizeNestedList.R
Created February 22, 2018 21:12 — forked from mrdwab/LinearizeNestedList.R
Un-nest a nested list in R
LinearizeNestedList <- function(NList, LinearizeDataFrames=FALSE,
NameSep="/", ForceNames=FALSE) {
# LinearizeNestedList:
#
# https://sites.google.com/site/akhilsbehl/geekspace/
# articles/r/linearize_nested_lists_in_r
#
# Akhil S Bhel
#
# Implements a recursive algorithm to linearize nested lists upto any
##--------------------------------------
## libraries
##--------------------------------------
library(rjson);
library(RCurl);
##--------------------------------------
## get data
##--------------------------------------
URL <- 'https://fm.formularynavigator.com/jsonFiles/publish/11/47/providers.json';
@aespar21
aespar21 / json_to_csv.py
Created March 9, 2018 21:00 — forked from poetix/json_to_csv.py
Short script to fetch JSON from MongoDB, flatten to dictionary of leaf nodes, and write everything out in CSV format
#!/usr/bin/python
import urllib2
import argparse
import json
parser = argparse.ArgumentParser(description="Fetch some JSON")
parser.add_argument("url")
args = parser.parse_args()
@aespar21
aespar21 / leg_violence_predict.R
Created May 3, 2018 18:42 — forked from christophergandrud/leg_violence_predict.R
Predict probability graphs with zelig and ggplot2
####################
# Create relogit predicted probabilities using Zelig and ggplot2
# Two Sword Lengths: Losers' Consent and Violence in National Legislatures (Working Paper 2012)
# Christopher Gandrud
# Updated 26 April 2012
###################
## Load required packages
library(RCurl)
library(Zelig)