Skip to content

Instantly share code, notes, and snippets.

@fototo
fototo / ExampleExamCode.R
Created January 18, 2016 06:25 — forked from vasishth/ExampleExamCode.R
Example code for automatically generating R exercises and exams
## Load library:
library("exams")
## exam questions:
myexamlist<-list("pnorm1","sesamplesize1multiplechoice")
## output directory
## create new test dir if one does not exist:
files.list<-system("ls",intern=TRUE)
@fototo
fototo / zellig.r
Created January 7, 2016 02:00 — forked from hrbrmstr/zellig.r
Single-source file for http://bit.ly/zellingenach
#' The single-file, 'source'-able version of https://github.com/hrbrmstr/zellingenach
#' More info here: http://bit.ly/zellingenach
#' By @hrbrmstr (2016)
#' MIT LICENSE
# NOTE THAT YOU NEED INTERNET ACCESS TO RUN THIS SCRIPT
# it pulls the three necessary files (only once) from my web site
library(V8)
library(dplyr)
@fototo
fototo / copulas_example.R
Created January 3, 2016 06:28 — forked from mick001/copulas_example.R
Modelling dependence with copulas. Full article at: http://datascienceplus.com/modelling-dependence-with-copulas/
#Load library mass and set seed
library(MASS)
set.seed(100)
# We are going to use 3 random variables
m <- 3
# Number of samples to be drawn
n <- 2000
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
belief y2015 y2014
Improves the security posture of my organization 0.75 0.71
Improves the security posture of the nations critical infrastructure 0.63 0.64
Reduces the cost of detecting and preventing cyber attacks 0.22 0.21
Improves situational awareness 0.60 0.54
Fosters collaboration among peers and industry groups 0.48 0.51
Enhances the timeliness of threat data 0.11 0.16
Makes threat data more actionable 0.21 0.24
@fototo
fototo / customer-segmentation.py
Last active September 14, 2015 23:49 — forked from glamp/customer-segmentation.py
Analysis for customer segmentation blog post
import pandas as pd
# http://blog.yhathq.com/static/misc/data/WineKMC.xlsx
df_offers = pd.read_excel("./WineKMC.xlsx", sheetname=0)
df_offers.columns = ["offer_id", "campaign", "varietal", "min_qty", "discount", "origin", "past_peak"]
df_offers.head()
df_transactions = pd.read_excel("./WineKMC.xlsx", sheetname=1)
df_transactions.columns = ["customer_name", "offer_id"]
df_transactions['n'] = 1
df_transactions.head()
@fototo
fototo / Rakefile
Last active September 14, 2015 00:06 — forked from jerodsanto/Rakefile
A code dump showing how we generate "The Changelog Weekly" using the Trello API
require "rubygems"
require "bundler"
require_relative "lib/importer"
Bundler.setup
desc "Import from Trello board"
task :import do
Importer.new(File.dirname(__FILE__)).import ENV["ISSUE"]
end
@fototo
fototo / sna_example.R
Last active August 29, 2015 14:25 — forked from dsparks/sna_example.R
Flag similarity network
# Drawing a scatter plot of raster images
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("png", "sna")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Go to https://www.gosquared.com/resources/2400-flags, download the ZIP,
# and put the 64 x 64 files into a directory of your choosing.
# Then setwd() to that directory:
setwd("C:/Dropbox/isDotR_Files/flagIcons")
@fototo
fototo / us_states_hexgrid.geojson
Last active August 29, 2015 14:25 — forked from hrbrmstr/us_states_hexgrid.geojson
hexbin faceted choropleths in R
library(rgdal)
library(rgeos)
library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(grid)
us <- readOGR("us_states_hexgrid.geojson", "OGRGeoJSON")
@fototo
fototo / README.md
Last active August 29, 2015 14:23 — forked from e9t/README.md