[Returnanalytics-commits] r2086 - pkg/MPO/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 28 03:28:06 CEST 2012
Author: jamesleehobbs
Date: 2012-06-28 03:28:06 +0200 (Thu, 28 Jun 2012)
New Revision: 2086
Added:
pkg/MPO/R/buildDataSet.R
Log:
- Market cap classification and beginning of building data set
Added: pkg/MPO/R/buildDataSet.R
===================================================================
--- pkg/MPO/R/buildDataSet.R (rev 0)
+++ pkg/MPO/R/buildDataSet.R 2012-06-28 01:28:06 UTC (rev 2086)
@@ -0,0 +1,30 @@
+### get data
+library(xts)
+library(quantmod)
+library(PerformanceAnalytics)
+
+###TODO load from package
+file.choose()
+mktCap <- read.csv("N:\\School\\Summer 2012\\Data Set\\Market Cap Data\\mktCapSummary.csv",as.is=TRUE)
+classifiers <- c("class.2011","class.12yrAvg","class.2yrAvg")
+large <- 10000
+mid <- 2000
+small <- 250
+
+
+### Classify tickers into market cap classes
+# mktCap > 10,000 large
+# > 2,000 and <10,000 mid
+# > 250 and <2,000 small
+# < 250 micro
+for (i in 1:length(classifiers)){
+ mktCap[mktCap[,1+i] >= large,classifiers[i]] <- "large"
+ mktCap[mktCap[,1+i] >= mid & mktCap[,1+i] < large ,classifiers[i]] <- "mid"
+ mktCap[mktCap[,1+i] >= small & mktCap[,1+i] < mid ,classifiers[i]] <- "small"
+ mktCap[mktCap[,1+i] <= small,classifiers[i]] <- "micro"
+}
+
+#Test
+mktCap[mktCap[,"Ticker"]=="AAPL",]
+
+###TODO Select smaller subset of tickers (~100) per group
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list