Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Compare Titles of the U.S. Code by some common measures.
# @date 20130818
# @author Bommarito Consulting, LLC; michael@bommaritollc.com
# @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
Something went wrong with that request. Please try again.