Skip to content

Instantly share code, notes, and snippets.

View horizon plot of french 48 industry portfolio.r
#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"
View findPrimes.R
##################################################################
# 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 Jan 27, 2012 — forked from deepakdodo/ai-class.py
Download lecture videos of ai-class (with Subtitles) (Stanford)
View ai-class.py
#!/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"
View upstream_challenge.R
#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 Dec 8, 2011 — forked from cboettig/lsos.R
List data size of objects in R
View lsos.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)