Last active
December 21, 2015 07:08
-
-
Save mjbommar/6268514 to your computer and use it in GitHub Desktop.
Compare Titles of the U.S. Code by some common measures.
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
# @date 20130818 | |
# @author Bommarito Consulting, LLC; [email protected] | |
# @page http://bommaritollc.com/?p=1067 | |
# Load libraries | |
library(ggplot2) | |
# Load data from git master | |
title_data <- read.csv('https://raw.github.com/mjbommar/us-code-complexity/master/results/table_data.csv', | |
header=T, | |
colClasses=c('factor', rep('numeric', 14))) | |
names(title_data)[2:5] <- c('ElementCount', 'SuperSectionCount', 'SectionCount', 'SubSectionCount') | |
# Plot descending word count | |
token_title_data <- title_data[order(-title_data$Tokens), c('Title', 'Tokens')] | |
token_title_data$TitleN <- reorder(token_title_data$Title, token_title_data$Tokens) | |
ggplot(token_title_data, aes(x=TitleN, y=Tokens)) + | |
geom_bar(stat="identity") + | |
scale_y_continuous("Tokens") + | |
scale_x_discrete("Title") + | |
coord_flip() | |
# Plot descending words per section count | |
tps_title_data <- title_data[order(-title_data$SectionCount), c('Title', 'TokensPerSection')] | |
tps_title_data$TitleN <- reorder(tps_title_data$Title, tps_title_data$TokensPerSection) | |
ggplot(tps_title_data, aes(x=TitleN, y=TokensPerSection)) + | |
geom_bar(stat="identity") + | |
scale_y_continuous("TokensPerSection") + | |
scale_x_discrete("Title") + | |
coord_flip() | |
# Plot descending element count | |
element_title_data <- title_data[order(-title_data$ElementCount), c('Title', 'ElementCount')] | |
element_title_data$TitleN <- reorder(element_title_data$Title, element_title_data$ElementCount) | |
ggplot(element_title_data, aes(x=TitleN, y=ElementCount)) + | |
geom_bar(stat="identity") + | |
scale_y_continuous("ElementCount") + | |
scale_x_discrete("Title") + | |
coord_flip() | |
# Plot descending section count | |
element_title_data <- title_data[order(-title_data$SectionCount), c('Title', 'SectionCount')] | |
element_title_data$TitleN <- reorder(element_title_data$Title, element_title_data$SectionCount) | |
ggplot(element_title_data, aes(x=TitleN, y=SectionCount)) + | |
geom_bar(stat="identity") + | |
scale_y_continuous("SectionCount") + | |
scale_x_discrete("Title") + | |
coord_flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment