Last active
August 29, 2015 14:27
-
-
Save colltoaction/c725d459bedd52662c9a to your computer and use it in GitHub Desktop.
7506 finger exercise 1
This file contains hidden or 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
train <- read.csv("train.csv") | |
ss <- subset(train, select=c("Descript")) | |
which.max(table(ss)) | |
# GRAND THEFT FROM LOCKED AUTO | |
ss <- subset(train, Category=="DRIVING UNDER THE INFLUENCE", select=c("DayOfWeek")) | |
which.max(table(ss)) | |
# Saturday | |
ss <- subset(train, select=c("PdDistrict")) | |
sort(table(ss), decreasing = TRUE)[1:3] | |
# SOUTHERN, MISSION, NORTHERN | |
ss <- prop.table(table(train$Category, train$Resolution), 1)[, "NOT PROSECUTED"] | |
sort(ss, decreasing = TRUE)[1:3] | |
# FORGERY/COUNTERFEITING, FRAUD, BAD CHECKS | |
ss <- subset(train, select=c("DayOfWeek")) | |
fss <- factor(ss$DayOfWeek, levels=c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"), ordered=TRUE) | |
pdf(height = 5, width = 9) | |
barplot(table(fss), 40) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment