Skip to content

Commit

Permalink
Added vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgovan committed Oct 26, 2016
1 parent 7fbf97d commit 3f21a8c
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 38 deletions.
7 changes: 5 additions & 2 deletions Description
@@ -1,5 +1,5 @@
Package: eAnalytics
Version: 0.1.0
Version: 0.1.1
Title: Dynamic Web-Based Analytics for the Energy Industry
Description: A 'Shiny' web application for energy industry analytics.
Take an overview of the industry, measure Key Performance Indicators,
Expand All @@ -9,7 +9,7 @@ BugReports: https://github.com/paulgovan/eanalytics/issues
Authors@R: person("Paul", "Govan", email = "pgovan1@aggienetwork.com", role = c("aut", "cre"))
Depends:
R (>= 2.10.0),
plotly,
plotly (>= 3.6.0),
License: Apache License
LazyData: TRUE
Imports:
Expand All @@ -22,3 +22,6 @@ Imports:
shiny,
shinydashboard
RoxygenNote: 5.0.1
Suggests: knitr,
rmarkdown
VignetteBuilder: knitr
6 changes: 6 additions & 0 deletions NEWS.md
@@ -0,0 +1,6 @@
# eAnalytics 0.1.1

## Major changes

* Added the ability to save data to a csv file
* Updated upstream dependency 'energyr'
14 changes: 1 addition & 13 deletions cran-comments.md
Expand Up @@ -3,19 +3,7 @@
* win-builder (devel and release)

## R CMD check results
There were no ERRORs or WARNINGs.

There was 1 NOTE:

* NOTE Maintainer: 'Paul Govan <pgovan1@aggienetwork.com>'

New submission

Possibly mis-spelled words in DESCRIPTION:
Analytics (3:20)
analytics (4:60)

* These words have the correct spelling.
There were no ERRORs, WARNINGs, or NOTEs.

## Downstream dependencies
There are currently no downstream dependencies for this package.
35 changes: 12 additions & 23 deletions inst/app/server.r
Expand Up @@ -8,24 +8,20 @@ data(pipeline, package = "energyr")
data(lng, package = "energyr")

# Aggregate pipeline data for googleVis chart
motionData <-
dplyr::select(pipeline, Type, Year, Cost, Miles, Capacity)
motionData <- dplyr::select(pipeline, Type, Year, Cost, Miles, Capacity)
motionData <- dplyr::filter(motionData,!is.na(Year))
motionData[is.na(motionData)] <- 0
motionData <- aggregate(
motionData[, 3:5],
by = list(Year = motionData$Year, Type = motionData$Type),
FUN = sum
)
motionData$Year <-
as.Date(as.character(motionData$Year), format = "%Y")
motionData$Year <- as.Date(as.character(motionData$Year), format = "%Y")

# Calculate the number of unique companies, projects, and facilities in database
company <-
length(unique(electric[, 1])) + length(unique(hydropower[, "Company"])) + length(unique(gas[, 1])) + length(unique(storage[, "Company"])) + length(unique(lng[, "Company"])) + length(unique(oil[, 1]))
company <- length(unique(electric[, 1])) + length(unique(hydropower[, "Company"])) + length(unique(gas[, 1])) + length(unique(storage[, "Company"])) + length(unique(lng[, "Company"])) + length(unique(oil[, 1]))
project <- length(unique(pipeline[, "Name"]))
facility <-
length(unique(hydropower[, "Name"])) + length(unique(storage[, "Field"])) + length(unique(lng[, "Company"]))
facility <- length(unique(hydropower[, "Name"])) + length(unique(storage[, "Field"])) + length(unique(lng[, "Company"]))

shiny::shinyServer(function(input, output, session) {
# Create the projects box
Expand Down Expand Up @@ -69,7 +65,7 @@ shiny::shinyServer(function(input, output, session) {
}
plotly::plot_ly(electric,
x = Year,
y = Rate,
y = Revenue,
group = Company)
})

Expand Down Expand Up @@ -102,8 +98,7 @@ shiny::shinyServer(function(input, output, session) {
"<br><strong>Capacity (KW): </strong>",
hydropower$Capacity
)
pal <-
leaflet::colorFactor(c("navy", "red"), domain = c("Expired", "Active"))
pal <- leaflet::colorFactor(c("navy", "red"), domain = c("Expired", "Active"))
leaflet::leaflet(hydropower) %>%
leaflet::fitBounds(-125, 49,-62, 18) %>%
leaflet::addProviderTiles("Esri.WorldStreetMap", group = "World Street Map") %>%
Expand Down Expand Up @@ -165,8 +160,7 @@ shiny::shinyServer(function(input, output, session) {
"<br><strong>Total Capacity (BCF): </strong>",
storage$Total
)
pal <-
leaflet::colorFactor(c("navy", "red", "green"),
pal <- leaflet::colorFactor(c("navy", "red", "green"),
domain = c("Depleted Field", "Salt Dome", "Aquifer"))
if (input$storageSize == "Total") {
leaflet::leaflet(storage) %>%
Expand Down Expand Up @@ -241,8 +235,7 @@ shiny::shinyServer(function(input, output, session) {
lng$Capacity
)
if (input$lngColor == "type") {
pal <-
leaflet::colorFactor(c("navy", "red"), domain = c("Export", "Import"))
pal <- leaflet::colorFactor(c("navy", "red"), domain = c("Export", "Import"))
leaflet::leaflet(lng) %>%
leaflet::addProviderTiles("Esri.WorldStreetMap", group = "World Street Map") %>%
leaflet::addProviderTiles("CartoDB.DarkMatter", group = "Dark Matter") %>%
Expand Down Expand Up @@ -326,8 +319,7 @@ shiny::shinyServer(function(input, output, session) {

# Draw a natural gas pipeline heatmap
output$heatmap <- d3heatmap::renderD3heatmap({
pipeline <-
subset(pipeline, select = c("Cost", "Miles", "Capacity"))
pipeline <- subset(pipeline, select = c("Cost", "Miles", "Capacity"))
dfcor <- cor(pipeline, use = "complete.obs")
dfvar <- dfcor ^ 2 * 100

Expand All @@ -349,14 +341,11 @@ shiny::shinyServer(function(input, output, session) {
output$boxplot <- plotly::renderPlotly({
pipeline <- na.omit(pipeline)
if (input$gas == "cost") {
cost <-
data.frame(Year = pipeline[, "Year"], Cost = pipeline[, "Cost"])
cost <- data.frame(Year = pipeline[, "Year"], Cost = pipeline[, "Cost"])
} else if (input$gas == "costMile") {
cost <-
data.frame(Year = pipeline[, "Year"], Cost = pipeline[, "Cost"] / pipeline[, "Miles"])
cost <- data.frame(Year = pipeline[, "Year"], Cost = pipeline[, "Cost"] / pipeline[, "Miles"])
} else if (input$gas == "costCap") {
cost <-
data.frame(Year = pipeline[, "Year"], Cost = pipeline[, "Cost"] / pipeline[, "Capacity"])
cost <- data.frame(Year = pipeline[, "Year"], Cost = pipeline[, "Cost"] / pipeline[, "Capacity"])
}
plotly::plot_ly(cost,
y = Cost,
Expand Down
93 changes: 93 additions & 0 deletions vignettes/eAnalytics.Rmd
@@ -0,0 +1,93 @@
---
title: "eAnalytics: Dynamic Web-based Analytics for the Energy Industry"
author: "Paul Govan"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{An Introduction to eAnalytics}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

eAnalytics is a [Shiny](http://shiny.rstudio.com) web application built on top of [R](https://www.r-project.org) for energy-related data analytics. The app is powered by the excellent [plotly](https://plot.ly/r/), [Leaflet](https://rstudio.github.io/leaflet/), [DT](https://rstudio.github.io/DT/), and [googleVis](https://cran.r-project.org/web/packages/googleVis/vignettes/googleVis_examples.html) packages. To learn more about our project, see this [publication](http://ascelibrary.org/doi/abs/10.1061/9780784413012.143).

# Getting Started
To install eAnalytics in R:

```c
install.packages("eAnalytics")
```

Or to install the latest developmental version:

```c
devtools::install_github('paulgovan/eAnalytics')
```
To launch the app:
```c
eAnalytics()
```

Or to access the app through a browser, visit [paulgovan.shinyapps.io/eAnalytics](https://paulgovan.shinyapps.io/eAnalytics).

# Data
eAnalytics is built around the [energyr](https://github.com/paulgovan/energyr) R package of data published by the United States Federal Energy Regulatory Commission [www.ferc.gov](www.ferc.gov). energyr contains several datasets for different industry segments:

* Electric Company Financial Data
* Natural Gas Company Financial Data
* Hydropower Plant Data
* LNG Plant Data
* Oil Company Financial Data
* Natural Gas Pipeline Project Data
* Natural Gas Storage Field Data

# Tutorial

## Dashboard
Launching the app first brings up the Dashboard tab, which is basically a landing page that gives a brief introduction to the app and includes three value boxes for the current number of projects, companies, and facilities in the database.

<img src="https://github.com/paulgovan/eAnalytics/blob/master/inst/images/Dashboard.png?raw=true" height="500px" />

## Profile
The Profile tab contains a number of interactive maps with information about facilities for the selected industry. The figure below shows the Profile tab for the Natural Gas Industry.

Multiple options are currently available for customizing the maps. Choose a preferred size or color variable in the movable well panel, select from different basemaps via the lower-right control, and click on a specific facility to view additional information.

<img src="https://github.com/paulgovan/eAnalytics/blob/master/inst/images/Profile2.png?raw=true" height="500px" />

## Performance
The Performance tab tracks a number of Key Performance Indicators (KPIs) for the selected industry. The following figure shows the Performance tab for the Natural Gas Industry.

<img src="https://github.com/paulgovan/eAnalytics/blob/master/inst/images/Performance2.png?raw=true" height="500px" />

## Trends

The Trends tab contains multiple interactive time-series charts of financial information for the selected industry. The following figure shows the Performance tab for the Electric industry.

The time-series chart in the Trends tab is linked to the data table shown in the Data tab. Searching, filtering, and sorting the data in the data table will automatically update the time-series chart with the selected data.

<img src="https://github.com/paulgovan/eAnalytics/blob/master/inst/images/Trends2.png?raw=true" height="500px" />

## Data
The Data tab contains interactive datatables of information for the selected industry. The data can be searched, filtered, and sorted as required. The selected data can then be copied to the clipboard, downloaded to a csv or pdf file, or sent to a local printer. The figure below shows the Data tab for the Hydropower industry.

<img src="https://github.com/paulgovan/eAnalytics/blob/master/inst/images/Data.png?raw=true" height="500px" />

## Explorer
The Explorer tab contains a dynamic motion chart for exploring several indicators over time. The following figure shows the Explorer tab for the Natural Gas Industry.

<img src="https://github.com/paulgovan/eAnalytics/blob/master/inst/images/Explorer2.png?raw=true" height="500px" />

# Source Code
eAnalytics is an [open source](http://opensource.org) project, and the source code and project data is available at [https://github.com/paulgovan/eAnalytics](https://github.com/paulgovan/eAnalytics)

# Issues
For issues or requests, please use the GitHub issue tracker at [https://github.com/paulgovan/eAnalytics/issues](https://github.com/paulgovan/eAnalytics/issues)

# Contributions
Ccontributions are welcome by sending a [pull request](https://github.com/paulgovan/eAnalytics/pulls)

# License
eAnalytics is licensed under the [Apache](http://www.apache.org/licenses/LICENSE-2.0) licence. &copy; Paul Govan (2016)

0 comments on commit 3f21a8c

Please sign in to comment.