This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 AL | |
2 AK | |
4 AZ | |
5 AR | |
6 CA | |
8 CO | |
9 CT | |
10 DE | |
11 DC | |
12 FL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state | code | num | census | icpsr | icpsr2 | |
---|---|---|---|---|---|---|
Alabama | AL | 1 | South | 41 | 41 AL ALABAMA | |
Alaska | AK | 2 | West | 81 | 81 AK ALASKA | |
Arizona | AZ | 3 | West | 61 | 61 AZ ARIZONA | |
Arkansas | AR | 4 | South | 42 | 42 AR ARKANSAS | |
California | CA | 5 | West | 71 | 71 CA CALIFORNIA | |
Colorado | CO | 6 | West | 62 | 62 CO COLORADO | |
Connecticut | CT | 7 | Northeast | 1 | 01 CT CONNECTICUT | |
Delaware | DE | 8 | South | 11 | 11 DE DELAWARE | |
District of Columbia | DC | 9 | Northeast | 55 | 55 DC DISTRICT OF COLUMBIA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load libs | |
library(ggplot2) | |
# Simulate correlated data | |
R = matrix(cbind(1,.80, .80,1), nrow=2) | |
U = t(chol(R)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Text from Searchable pdfs | |
Scrape Text off Wisconsin Ads pdfs | |
Uses pyPdf to get text from searchable pdfs. The script is for tailored for getting data | |
from Wisconsin Political Ads Database: http://wiscadproject.wisc.edu/Storyboards. | |
@author: Gaurav Sood | |
Created on November 02, 2011 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the data | |
sf <- read.csv("sf_tenants.csv") | |
# Recode | |
sf$market_rates <- gsub("%", "", sapply(strsplit(sf$market_rate, " / "), "[", 2)) # market_rate | |
sf$rent_control_rates <- gsub("%", "", sapply(strsplit(sf$rent_control, " / "), "[", 2)) # market_rate | |
# Ratio of rent_control vs. rent_control | |
sf$ratio <- as.numeric(sf$rent_control_rates)/as.numeric(sf$market_rates) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
Basic Text Classifier | |
- Takes a csv with a text column, and column of labels | |
- Splits into train and test | |
- Preprocesses text using tm/bag-of-words, 1/2-order Markov | |
- Uses SVM and Lasso | |
@author: Gaurav Sood | |
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> median(FALSE) | |
[1] FALSE | |
> median(c(TRUE, FALSE)) | |
[1] 0.5 | |
> median(c(TRUE, FALSE, TRUE)) | |
[1] TRUE | |
> f <- factor(c('a', 'b', 'c'), levels = c('a', 'b', 'c'), ordered = TRUE) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Manual classification of observations | |
#' | |
#' \code{classify} launches a Shiny app to manually classify a subset of observations. | |
#' | |
#' @param x A character vector. | |
#' @param btn_labels A character vector of length 2 corresponding to 0 and 1. | |
#' @return A vector of 0/1 for each element in \code{x}. | |
#' @export | |
#' @examples \dontrun{ | |
#' foo <- sprintf('%s (%.2f miles per gallon)', rownames(mtcars), mtcars$mpg) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.