Difference between revisions of "Power.R"

From Organic Design wiki
m
(Add auxillary data)
Line 48: Line 48:
  
 
# Estimated monthly usage between May and September
 
# Estimated monthly usage between May and September
tapply(dset$"DailyConsumption"[-1], cumsum(dset$Estimate[-1]), mean)
+
dset$GroupReads <- cumsum(dset$Estimate)
 +
smoothedDailyLevels <- tapply(dset$"DailyConsumption"[-1], cumsum(dset$Estimate[-1]), mean)
 +
dset$smoothedDaily[3:22] <- c(0,11,80,smoothedDailyLevels[dset$GroupReads))

Revision as of 00:32, 11 October 2006

vnames <- c("Date","Reading","Estimate","DailyConsumption","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$"DailyConsumption" <- as.numeric(levels(dset$"DailyConsumption"))[unclass(dset$"DailyConsumption")] dset$Estimate <- as.numeric(levels(dset$Estimate))[unclass(dset$Estimate)]

dset$date <- dates(levels(dset$Date)[unclass(dset$Date)])


library(chron)

plot(DailyConsumption~Date, data=dset) points(dset$Date[dset$Estimate==0], dset$"DailyConsumption"[dset$Estimate==0], col="blue", pch=16, cex=1)

  1. Estimated monthly usage between May and September

mean(dset[18:21,4])

  1. Estimated monthly usage between May and September

dset$GroupReads <- cumsum(dset$Estimate) smoothedDailyLevels <- tapply(dset$"DailyConsumption"[-1], cumsum(dset$Estimate[-1]), mean) dset$smoothedDaily[3:22] <- c(0,11,80,smoothedDailyLevels[dset$GroupReads))