Created
May 16, 2015 19:40
-
-
Save munroebot/7ae82726b9065de6ae43 to your computer and use it in GitHub Desktop.
NV Energy Bill 13 Month Analysis
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
library(dplyr) | |
# Read in the data from a comma seperated value file. | |
data <- read.csv("BillHistory.csv", stringsAsFactors=TRUE,skip=6) | |
# transform it into a data.table | |
data <- tbl_df(data) | |
# print the data table | |
data | |
# Source: local data frame [13 x 5] | |
# | |
# Bill.Date Balance.Forward Electric.Usage..kWh. Current..Charges | |
# 1 5/13/2015 $0.00 643 $97.28 | |
# 2 4/14/2015 $0.00 820 $120.29 | |
# 3 3/13/2015 $0.00 812 $119.22 | |
# 4 2/11/2015 $0.00 741 $109.96 | |
# 5 1/13/2015 $0.00 935 $133.65 | |
# 6 12/11/2014 $0.00 833 $119.73 | |
# 7 11/08/2014 $0.00 769 $111.32 | |
# 8 10/11/2014 $0.00 1316 $182.73 | |
# 9 9/13/2014 $0.00 1913 $260.78 | |
# 10 8/14/2014 $0.00 2383 $322.27 | |
# 11 7/15/2014 $0.00 2060 $281.56 | |
# 12 6/14/2014 $0.00 1660 $229.73 | |
# 13 5/14/2014 $0.00 779 $113.37 | |
# Variables not shown: Total.Amount (fctr) | |
# Keep only three columns from the table, dropping the rest | |
data <- select(data,Bill.Date, Electric.Usage..kWh.,Current..Charges) | |
# Rename the column names to something a little less strange (removing | |
# the double dots .. ) | |
colnames(data) <- c("Bill.Date","Electric.Usage.kWh","Current.Charges") | |
# Change the Bill.Date into a date data type | |
data$Bill.Date <- as.Date(data$Bill.Date,"%m/%d/%Y") | |
# Remove the dollar-signs from the Current..Charges field and | |
# then turn them in to a numerical data type since we | |
# need to do math on them | |
data$Current.Charges <- gsub("\\$","",data$Current.Charges) | |
data$Current.Charges <- as.numeric(data$Current.Charges) | |
# print the data table again (notice is has only three columns) | |
data | |
# Source: local data frame [13 x 3] | |
# | |
# Bill.Date Electric.Usage.kWh Current.Charges | |
# 1 2015-05-13 643 97.28 | |
# 2 2015-04-14 820 120.29 | |
# 3 2015-03-13 812 119.22 | |
# 4 2015-02-11 741 109.96 | |
# 5 2015-01-13 935 133.65 | |
# 6 2014-12-11 833 119.73 | |
# 7 2014-11-08 769 111.32 | |
# 8 2014-10-11 1316 182.73 | |
# 9 2014-09-13 1913 260.78 | |
# 10 2014-08-14 2383 322.27 | |
# 11 2014-07-15 2060 281.56 | |
# 12 2014-06-14 1660 229.73 | |
# 13 2014-05-14 779 113.37 | |
# Show some summary statistics from about the data | |
summary(data) | |
# Bill.Date Electric.Usage.kWh Current.Charges | |
# 1/13/2015 :1 Min. : 643 Min. : 97.28 | |
# 10/11/2014:1 1st Qu.: 779 1st Qu.:113.37 | |
# 11/08/2014:1 Median : 833 Median :120.29 | |
# 12/11/2014:1 Mean :1205 Mean :169.38 | |
# 2/11/2015 :1 3rd Qu.:1660 3rd Qu.:229.73 | |
# 3/13/2015 :1 Max. :2383 Max. :322.27 | |
# (Other) :7 | |
# Plot the amount of energy used by date | |
plot(data$Bill.Date, data$Electric.Usage.kWh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment