Last updated: 2026-03-02
Checks: 6 1
Knit directory: dickinson_power/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of
the R Markdown file created these results, you’ll want to first commit
it to the Git repo. If you’re still working on the analysis, you can
ignore this warning. When you’re finished, you can run
wflow_publish to commit the R Markdown file and build the
HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20260107) was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 1ea78ae. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish or
wflow_git_commit). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/.DS_Store
Ignored: data/FY25 Main Meter Data.xlsx
Ignored: data/building_list_FY25_updated.xlsx
Ignored: data/graph_data_life_exp.csv
Ignored: keys/.DS_Store
Ignored: output/building_check.csv
Ignored: output/building_check.xlsx
Ignored: output/kwh_annual.csv
Ignored: output/kwh_annual_20260225.csv
Ignored: output/kwh_annual_20260226.csv
Ignored: output/kwh_daily.csv
Ignored: output/kwh_daily_20260225.csv
Ignored: output/kwh_daily_20260226.csv
Ignored: output/kwh_main_annual.csv
Ignored: output/kwh_main_daily.csv
Unstaged changes:
Modified: analysis/_site.yml
Modified: analysis/data_wrangling_final.Rmd
Modified: analysis/main_meter_processing.Rmd
Modified: keys/occupancy_key.csv
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown (analysis/main_meter_processing.Rmd)
and HTML (docs/main_meter_processing.html) files. If you’ve
configured a remote Git repository (see ?wflow_git_remote),
click on the hyperlinks in the table below to view the files as they
were in that past version.
| File | Version | Author | Date | Message |
|---|---|---|---|---|
| Rmd | e752845 | maggiedouglas | 2026-02-26 | adjust data processing + building summary |
| Rmd | 182fffe | maggiedouglas | 2026-02-16 | add temp to main meter building data |
| html | 182fffe | maggiedouglas | 2026-02-16 | add temp to main meter building data |
| Rmd | 1e2d797 | maggiedouglas | 2026-02-15 | Processed main meter data |
| html | 1e2d797 | maggiedouglas | 2026-02-15 | Processed main meter data |
This code loads and processes the data for individual buildings on the main meter, combines them into a single dataset, and summarizes the completeness of the data.
library(tidyverse)
library(readxl)
library(DT)
# load names of tabs
sheet <- excel_sheets("./data/FY25 Main Meter Data.xlsx")
# applying sheet names to dataframe names
data <- lapply(setNames(sheet, sheet),
function(x)
read_excel("./data/FY25 Main Meter Data.xlsx", sheet=x))
# load temp data
temp <- read.csv("./keys/temp_by_date.csv") %>%
mutate(date = mdy(date))
# attaching all dataframes together
## (reads in two kWh columns b/c slightly diff names)
main_bldgs <- bind_rows(data, .id="Sheet") %>%
rename(building = Sheet,
date = Date,
kWh1 = 3,
kWh2 = 4) %>%
mutate(kwh = ifelse(is.na(kWh1), kWh2, kWh1), # reconcile kWh to condense to one column
date = mdy(date)) %>%
filter(date < ymd("2025-07-01"), # filter to fiscal year 25
date > ymd("2024-06-30")) %>%
select(-kWh1, -kWh2) %>% # remove extra kWh columns
mutate(month = month(date, label = TRUE),
day = wday(date, label = TRUE)) %>% # generate month and day
select(building, month, day, date, kwh) %>%
left_join(temp, by = "date") # add back in temperature + DD
str(main_bldgs)
tibble [8,395 × 8] (S3: tbl_df/tbl/data.frame)
$ building: chr [1:8395] "Althouse" "Althouse" "Althouse" "Althouse" ...
$ month : Ord.factor w/ 12 levels "Jan"<"Feb"<"Mar"<..: 7 7 7 7 7 7 7 7 7 7 ...
$ day : Ord.factor w/ 7 levels "Sun"<"Mon"<"Tue"<..: 2 3 4 5 6 7 1 2 3 4 ...
$ date : Date[1:8395], format: "2024-07-01" "2024-07-02" ...
$ kwh : num [1:8395] 339 346 351 344 336 212 223 362 370 384 ...
$ ave_temp: int [1:8395] 69 73 78 81 84 86 84 84 86 87 ...
$ cdd_65 : num [1:8395] 6 9.6 13.5 16.2 20.1 22.2 19 19.7 22.4 22.6 ...
$ hdd_65 : num [1:8395] 0 1.3 0 0 0 0 0 0 0 0 ...
# store main meter total kwh from PPL data
main_tot <- 11648808
annual_non_na <- main_bldgs %>%
filter(!is.na(kwh)) %>%
group_by(building) %>%
summarize(non_na = n())
annual <- main_bldgs %>%
group_by(building) %>%
summarize(kwh = round(sum(kwh, na.rm = T), digits = 0),
days = n()) %>%
left_join(annual_non_na, by = "building") %>%
mutate(perc_days = round((non_na/days)*100, digits = 0))
# which are the missing days?
annual_missing <- main_bldgs %>%
filter(is.na(kwh)) %>%
group_by(date) %>%
summarize(n = n())
# store total for all submetered buildings
indiv_tot <- sum(annual$kwh)
# What percentage of the total is captured here?
(indiv_tot / main_tot)*100
[1] 38.98098
ggplot(main_bldgs, aes(x = month, y = kwh, fill = building)) +
facet_wrap(. ~ building, scales = "free") +
geom_col(position = "stack") +
theme_bw() +
theme(legend.position = "none") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
labs(title = "Buildings with Submeters on the Main Meter",
x = "",
y = "Electricity use (kWh)")

| Version | Author | Date |
|---|---|---|
| 1e2d797 | maggiedouglas | 2026-02-15 |
Note: I’m guessing CHW corresponds to
central heating (?) This would be the part of Kaufman Hall that is
associated with producing energy for the rest of campus.
datatable(annual, filter = 'top', rownames=FALSE,
colnames = c("Building","Total kWh","# Days", "Days with data", "Days with data (%)"))
datatable(select(main_bldgs, building, date, kwh, ave_temp),
filter = 'top', rownames = FALSE, colnames = c("Building","Date","kWh", "Temp (F)"))
write.csv(annual, "./output/kwh_main_annual.csv", row.names = F)
write.csv(main_bldgs, "./output/kwh_main_daily.csv", row.names = F)
sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.7.8
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.33 readxl_1.4.3 lubridate_1.9.3 forcats_1.0.0
[5] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5
[9] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] sass_0.4.8 utf8_1.2.4 generics_0.1.3 stringi_1.8.3
[5] hms_1.1.3 digest_0.6.37 magrittr_2.0.3 timechange_0.3.0
[9] evaluate_0.23 grid_4.3.2 fastmap_1.1.1 cellranger_1.1.0
[13] rprojroot_2.0.4 workflowr_1.7.1 jsonlite_1.8.8 whisker_0.4.1
[17] promises_1.2.1 fansi_1.0.6 crosstalk_1.2.1 scales_1.3.0
[21] jquerylib_0.1.4 cli_3.6.2 rlang_1.1.3 ellipsis_0.3.2
[25] munsell_0.5.0 withr_3.0.0 cachem_1.0.8 yaml_2.3.8
[29] tools_4.3.2 tzdb_0.4.0 colorspace_2.1-0 httpuv_1.6.13
[33] vctrs_0.6.5 R6_2.5.1 lifecycle_1.0.4 git2r_0.33.0
[37] htmlwidgets_1.6.4 fs_1.6.3 pkgconfig_2.0.3 pillar_1.9.0
[41] bslib_0.6.1 later_1.3.2 gtable_0.3.4 glue_1.7.0
[45] Rcpp_1.1.0 highr_0.10 xfun_0.41 tidyselect_1.2.0
[49] rstudioapi_0.16.0 knitr_1.45 farver_2.1.1 htmltools_0.5.7
[53] labeling_0.4.3 rmarkdown_2.25 compiler_4.3.2