Skip to content

This is a tool that allows users to visualize the impacts of electric vehicle incentive attributes.

License

Notifications You must be signed in to change notification settings

m-mcqueen/Incentive-Impact-Tool

Repository files navigation

Incentive-Impact-Tool

This is a tool that allows users to visualize the impacts of electric vehicle incentive attributes.

Organization:

ui.R

This file contains the front-end ui code. It makes use of shinydashboard, shinyBS, and shinyjs.

  • Header: contains the Trec logo which links to Trec
  • Sidebar: contains an assortment of menuItems and input fields for feeding information to the app
  • Body: contains the output plots and sliders for adjusting the plot axes

server.R

This file performs the reactive calculations to supply outputs for the ui.

  • Intro Modal
    • Creates a pop up as soon as the app starts to introduce the app to the user. Click the button to close.
  • Plot Dimensions
    • These store input parameters in reactive vars for use in defining the plot axes limits.
  • Plot Colors
    • Defines the color palette to be used for plots. Uses a viridis colorblind accessible palette.
  • Text input preset value updaters
    • Observes that a preset "apply" button was pressed and retrieves the corresponding values to the preset that was selected
    • Saves the "state" of the input fields once the values have been updated.
  • Flags to know if a preset was applied
    • These flags indicate whether or not a preset is actually being used.
    • The flag is initialized as T as the default values belong to a preset
    • The flag becomes false if any of the input fields are changed by the user
    • The flag become true once a preset is applied again
    • This information is passed to the Report.Rmd in order for it to know whether or not to display information about the preset that was selected
  • Update the selection box toolTip
    • These event observers update the toolTips for each preset box to contain the preset description provided in the databases
    • They make use of shinyjs::delay in order to remove the existing toolTip and add a new toolTip sequentially
  • Limit the budget inputs to sum to 100 using observers
    • These event observers ensure that the user can never allot more than 100% of the total budget to all modes
  • Calcs
    • In this section, helper functions from util.R are called in order to calculate the min/max values of all of the lines that will be plotted. Only two points are calculated for each ggplot feature, since everything is a line. The min/max of each axis are used to determine which points should be calculated.
  • Plots
    • Calls the ggplot helper functions in util.R to generate plot outputs for the ui
  • Report
    • Passes several parameters of the current state of the app to the report.Rmd so that a report can be generated and saved

util.R

This file contains helper functions for calculations and plots referenced by server.R and report.Rmd.

  • General Helper Functions
    • These helper functions are used to exclude data if the "include" button hasn't been pressed and to calculate all relevant datapoints for reporting
  • Plotting Helper Functions
    • There is one helper function for each of the five graphs. They are accessed by both server.R and report.Rmd

global.R

This file contains code to load in the databases that are used by the app. It also contains some code that defines a few conversion constants using the units package.

  • Load data table
    • simply load the .Rdata file generated by process_data_for_web_use.R
  • Clean up tables to combine units with scalar values
    • take the units columns and joins it to the numerics using the units package, removes the units column. Units class objects can be used for calculations using the measurements package without having to worry about manual unit conversions.
  • Define Conversion Constants
    • There are some unit conversions that are needed that are not included in the measurements package. These are defined here. They can only be defined once per R session, otherwise an error is thrown. This code also catches these errors if the conversion constant is already defined in the session.

report.Rmd

This file is used to generate an html page containing all of the outputs from the app in an easily understandable format.

  • Results
    • Only the modes that were "included" using the button in the app are reported
  • Inputs
    • Only the modes that were "included" using the button in the app are reported
    • If presets were used, they are reported, along with their descriptions and links to the sources for the data.

intro_text.html

This file is called by the ui on startup to display as a popup welcome message to the user.

Incentive Impact Tool.Rproj

The R project file, useful to open when editing any R file.

www

At the top level, there are two logos used by the app

Data Tables

  • State Info and Vehicles: these folders contain data tables in csv format. These can be edited when adding new vehicles, mixes, electricity generation profiles, etc.
  • process_data_for_web_use.R: this file is used to convert the csv files to the data.RData file that is used by the app. This saves some server load on the back end.
  • data.RData: the aforementioned data file that is generated by process_data_for_web_use.R
  • NHTS_state_autotrip_info.R: Obtaining vehicle level VMT from the NHTS by state is a little tricky. This script should be used with NHTS/trippub.csv to calculate a list of mean vehicle VMT and number of trips per day.

About

This is a tool that allows users to visualize the impacts of electric vehicle incentive attributes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published