Difference between revisions of "Power.R"
(Fix original dset loading) |
(rv paste error) |
||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
vnames <- c("Date","Reading","Estimate","Daily consumption","cents per Kwh","Dollars") | vnames <- c("Date","Reading","Estimate","Daily consumption","cents per Kwh","Dollars") | ||
dset <- scan(sep=",", what="") | dset <- scan(sep=",", what="") |
Revision as of 00:15, 11 October 2006
vnames <- c("Date","Reading","Estimate","Daily consumption","cents per Kwh","Dollars") dset <- scan(sep=",", what="") 12/24/04,30987,0,0,0,0 01/19/05,31294,0,11.8,14.07,65.99 02/15/05,31910,1,22,14.07,116.26 03/15/05,32121,0,7.5,14.07,52.15 05/16/05,33114,0,17.9,14.07,113.79 06/15/05,33564,1,15,14.53,93.98 07/15/05,34765,0,40,14.53,216.7 08/16/05,35245,1,15,14.53,100.23 09/15/05,37356,0,70.4,14.53,365.44 10/17/05,37836,1,15,14.53,100.25 11/15/05,38957,0,38.7,14.53,211.28 12/16/05,39422,1,15,15.7,104.67 01/17/06,40115,0,21.7,15.7,145.69 02/14/06,40535,1,15,15.7,94.55 03/15/06,41148,0,21.1,15.7,129.33 04/12/06,41568,1,15,16.4,96.15 05/15/06,43284,0,52,16.4,341.09 06/15/06,44121,1,27,16.4,177.46 06/29/06,44241,1,9.23,14.78,24.83 08/31/06,44811,1,9.05,14.78,118.41 09/28/06,52471,0,273.57,14.78,1284.17 10/10/06,53080,0,50.75,14.78,"NA" ""
dim(dset) <- c(6,22) dset <- t(dset)
dset <- as.data.frame(dset) names(dset) <- vnames
dset dset dset$"Daily consumption" <- as.numeric(levels(dset$"Daily consumption"))[unclass(dset$"Daily consumption")] dset$date <- dates(levels(dset$Date)[unclass(dset$Date)])
library(chron)
- -------------------------------- Alternate read ------------------------------------ #
- setwd("C:/tmp/My Documents/Finance/Letters/Empower")
- dset <- read.table("empower_metre_reading.csv", sep=",", header=TRUE, as.is=TRUE)
- dset[,1] <- dates(dset[,1])
plot(Daily.consumption~Date, data=dset) points(dset$Date[dset$Estimate==0], dset$Daily.consumption[dset$Estimate==0], col="blue", pch=16, cex=1)
- Estimated monthly usage between May and September
mean(dset[18:21,4])
- Aggregated monthly usage based on average readings over estimated to actual reading periods
library(chron) setwd("C:/tmp/My Documents/Finance/Letters/Empower") dset <- read.table("empower_metre_reading.csv", sep=",", header=TRUE, as.is=TRUE) dset[,1] <- dates(dset[,1])
plot(Daily.consumption~Date, data=dset) points(dset$Date[dset$Estimate==0], dset$Daily.consumption[dset$Estimate==0], col="blue", pch=16, cex=1)
- Estimated monthly usage between May and September
tapply(dset$Daily.consumption[-1], cumsum(dset$Estimate[-1]), mean)