/PortfolioSandbox

An energy consumption and demand visualization sandbox for a portfolio of (anonymized) buildings. A R/Shiny application.

Primary LanguageR

Portfolio Visualization Sandbox

Portfolio Visualization Sandbox: Heatmaps + Boxplots

This project contains code for a R/Shiny application that produces several types of visualizations of energy use for portfolios of spaces over time. These portfolios are typically those of multi-space organizations such as universities, health care networks, or school boards.

An instance of the portfolio visualization sandbox is running on shinyapps.io. Username: ieeevis / password: vis2015.

These visualizations include ggplot2 implementations of faceted time-series line plots, stacked area charts, (calendar) heatmaps, bar charts, box plots, histogram/density plots, and a ranking visualization inspired by Caleydo's LineUp. The application also includes a map-based visualization using jcheng5's leaflet-shiny package.

There are 3 main views on portfolio data, each having a dedicated tab in the interface: (1) seasonal, monthly, or calendar heatmaps with aligned summary charts (boxplots, histogram/density plots, and bar charts), used for analysis at a coarse time granularity; (2) a "LineUp" ranking visualization, used for comparing a small number of itmes at coarse time granularities; (3) a stacked area with accompanying individual faceted line plots for fine-scale time-series load profile analysis.

Portfolio Visualization Sandbox: LineUp plot

Visualizations are drawn using reactive functions bound to global controls for selection, filtering, aggregation, and normalization. Time window filtering is accomplished with a date range selector, options to focus on daytime/nighttime and weekday/weekend, as well as with advanced options to filter by season or month. Space metadata filtering is accomplished using a conjunction of filters on space name, space use, use type, space type, tag, and city; advanced options are included to filter by space area, building age, occupant count, and operating hours. Spaces can be aggregated by shared space use, use type, space type, tag, and city. Their data can be normalized by space area, occupant count, and operating hours, as well as by weather (# HDDs and CDDs).

Portfolio Visualization Sandbox: Time Series Stacked Area chart with Faceted Line Charts

Portfolio Data

The application loads data from three sources:

  • [portfolio-name]/[portfolio-name]-performance.csv

1\ Performance data for all spaces in a portfolio.

  • [portfolio-name]/[portfolio-name]-metadata.csv

2\ Metadata for all spaces in a portfolio; currently, the application uses space name, city, space type, space use, use type, area, occupant count, weekly operating hours, year consructed / building age, latitude, and longitude

  • [portfolio-name]/[portfolio-name]-tags.csv

3\ Categorical tags for some or all spaces in a portfolio: a space can have zero, one, or more categorical descriptor tags, for adding more information about a space not captured by existing metadata fields

Example Data

An example portfolio is provided in the data/ folder. This contains space metadata, space tags, and energy use data for a small portfolio (6 spaces) over a time span of 2 years (Jan 2012 - Dec 2013) at a 4h granularity. Data for individual years is also provided. The performance data contains multiple resources (Electricity, Steam, Natural Gas), as well as measurements of Total, Total Baseload, and Electricity Baseload. 2012 Data is also used as a baseline for 2013 (paired data points are aligned to matching week numbers and weekdays).

The application has been used for university campus and school board portfolios with up to ~100 spaces.

Dependencies

Several packages are used, some of which require devtools to install the package from github. These include the newest development versions of shiny and leaflet. See global.R for other packages required from CRAN. Recommended: ggplot2, data.table, plyr, foreach, reshape2, grid, maps, scales, rjson.

Usage

Launch the Shiny application:

> shiny::runApp()

Or launch it from the terminal:

> R -e 'require(shiny); runApp(port=8100)' &.

This will process the data and open a new browser tab with debug statements output to the console. You may want to run this command as a separate process in a terminal such that it won't tie up your R/RStudio console environment.

Organization

The Shiny application itself is comprised of several files:

  • The data is loaded from csv in global.R. This file also tidies and formats data tables containing space performance data, space metadata, and space tags.

  • The user interface components (headers, divs, tabs, text content) is specified in ui.R.

  • The reactive controls for selecting, filtering, aggregating, and normalizing portfolio data is specified in the server directory, which are all sourced by server.R. Most of the visualization code lives here in individual server/plot---.R files.

  • Some additional non-reactive utility functions are specified in dataFunctions.R, including functions for filtering, ranking, and computing differentials.

Known Issues

  • Initial loading times can be on the order of a few minutes for large portfolios. Reactive functions can also take several seconds to complete before plots refresh. Be patient.

  • Cryptic Shiny error/warning messages will appear in the console. The Shiny debugger may help clarify these (command-F3 in the browser opens the Shiny call graph visualization in a new tab).

  • The latitude/longitude resolution for shape placement on leaflet maps is far from perfect, and appears to be a problem with the code that ports leaflet to R. Only 6 significant digits are used, including '-'; the effect of this for coordinates with longitude < -100 is quite apparent. This Google Groups thread discusses the issue, which as of Feb 17, 2014 is unresolved.