Skip to content

Instantly share code, notes, and snippets.

#get very helpful Ken French data
#for this project we will look at Industry Portfolios
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip
require(latticeExtra)
require(PerformanceAnalytics)
require(quantmod)
#my.url will be the location of the zip file with the data
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip"
@jedifran
jedifran / findPrimes.R
Created May 30, 2012 02:32
find primes
##################################################################
# Brute force method for finding all the prime numbers between
# nMin and nMax
##################################################################
findPrimes <- function(nMin, nMax) {
# make sure min number is larger than 1, and break if true
if (nMin == 1)
stop("\n\n **** Error: Please ensure nMin is larger than 1 (nMin > 1) ****")
@jedifran
jedifran / ai-class.py
Created January 27, 2012 19:18 — forked from deepakdodo/ai-class.py
Download lecture videos of ai-class (with Subtitles) (Stanford)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Deepak.G.R."
__license__ = 'Public Domain'
"""
usage:
Go to command line and type
python ai-class.py "topic-name"
@jedifran
jedifran / upstream_challenge.R
Created December 13, 2011 02:04
upstream challenge
#Challenge:
#Given the following set of numbers {49,8,48,15,47,4,16,23,43,44,42,45,46}. A function picks a random subset of size 6, and takes the minimum, what is the expected value of this function.
#put set of numbers into a container
test.set <- c(49,8,48,15,47,4,16,23,43,44,42,45,46)
#This function picks a random subset of size 6 and takes the minimum
upstream.fxn <- function(test.set) {min(sample(test.set,6));}
@jedifran
jedifran / lsos.R
Created December 8, 2011 15:45 — forked from cboettig/lsos.R
List data size of objects in R
## Credit: Taken from: http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session
# improved list of objects
.ls.objects <- function (pos = 1, pattern, order.by,
decreasing=FALSE, head=FALSE, n=5) {
napply <- function(names, fn) sapply(names, function(x)
fn(get(x, pos = pos)))
names <- ls(pos = pos, pattern = pattern)
obj.class <- napply(names, function(x) as.character(class(x))[1])
obj.mode <- napply(names, mode)
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)