GithubHelp home page GithubHelp logo

carbonr's Introduction

carbonr

R-CMD-check Codecov test coverage Lifecycle: experimental Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. CRAN status license

Overview

carbonr is a package in R to conveniently calculate carbon-equivalent emissions:

  • airplane_emissions()
  • ferry_emissions()
  • hotel_emissions()
  • office_emissions()
  • rail_emissions()
  • raw_fuels()
  • vehicle_emissions()

These all return carbon-equivalent emissions in tonnes. The emissions values in the calculations are from the UK Government report (2021).

A shiny app is also available by shiny_emissions() to calculate carbon-equivalent emissions with a GUI.

Installation

You can install the development version of carbonr from GitHub with:

# install.packages("devtools")
devtools::install_github("IDEMSInternational/carbonr")

Usage

library(carbonr)

# To calculate emissions for a flight between Vancouver and Toronto
airport_finder(name = "Vancouver")
#> # A tibble: 3 x 4
#>   Name                                  City      Country IATA 
#>   <chr>                                 <chr>     <chr>   <chr>
#> 1 Vancouver International Airport       Vancouver Canada  "YVR"
#> 2 Vancouver Harbour Water Aerodrome     Vancouver Canada  "CXH"
#> 3 Vancouver International Seaplane Base Vancouver Canada  "\\N"
airport_finder(name = "Toronto")
#> # A tibble: 2 x 4
#>   Name                                     City    Country IATA 
#>   <chr>                                    <chr>   <chr>   <chr>
#> 1 Billy Bishop Toronto City Centre Airport Toronto Canada  YTZ  
#> 2 Toronto/Oshawa Executive Airport         Oshawa  Canada  YOO
airplane_emissions("YVR", "YYZ")
#> [1] 0.9911252

# To calculate emissions for a round trip ferry from Melbourne to New York
seaport_finder(country = "Australia", city = "Melbourne")
#>     country                       city country_code port_code latitude
#> 1 Australia Point Henry Pier/Melbourne           AU       PHP   -38.07
#> 2 Australia             Port Melbourne           AU       POR   -37.50
#>   longitude
#> 1    144.26
#> 2    144.56
seaport_finder(country = "US", city = "New York")
#>         country              city country_code port_code latitude longitude
#> 1 United States Brooklyn/New York           US       BOY    40.44    -73.56
ferry_emissions("POR", "BOY", round_trip = TRUE)
#> [1] 4.422754

# To calculate emissions for a train journey from Bristol Temple Meads to Edinburgh Waverley, via Birmingham New Street.
rail_finder(station = "Bristol")
#> # A tibble: 2 x 7
#>   station_code station              region    county district latitude longitude
#>   <chr>        <chr>                <chr>     <chr>  <chr>       <dbl>     <dbl>
#> 1 BPW          Bristol Parkway      South We~ South~ South G~     51.5     -2.54
#> 2 BRI          Bristol Temple Meads South We~ Brist~ Bristol~     51.4     -2.58
rail_finder(station = "Edinburgh")
#> # A tibble: 2 x 7
#>   station_code station        region   county        district latitude longitude
#>   <chr>        <chr>          <chr>    <chr>         <chr>       <dbl>     <dbl>
#> 1 EDB          Edinburgh      Scotland Edinburgh Ci~ Edinbur~     56.0     -3.19
#> 2 EDP          Edinburgh Park Scotland Edinburgh Ci~ Edinbur~     55.9     -3.31
rail_finder(station = "Birmingham")
#> # A tibble: 5 x 7
#>   station_code station                 region county district latitude longitude
#>   <chr>        <chr>                   <chr>  <chr>  <chr>       <dbl>     <dbl>
#> 1 BBS          Birmingham Bordesley    West ~ West ~ Birming~     52.5     -1.88
#> 2 BHI          Birmingham Internation~ West ~ West ~ Solihull     52.5     -1.73
#> 3 BHM          Birmingham New Street   West ~ West ~ Birming~     52.5     -1.90
#> 4 BMO          Birmingham Moor Street  West ~ West ~ Birming~     52.5     -1.89
#> 5 BSW          Birmingham Snow Hill    West ~ West ~ Birming~     52.5     -1.90
rail_emissions(from = "Bristol Temple Meads", to = "Edinburgh", via = "Birmingham New Street")
#> [1] 0.02303694

# To calculate vehicle emissions for a 100 mile bus journey
vehicle_emissions(distance = 100, units = "miles", vehicle = "bus")
#> [1] 0.02356298

# Additional emissions can be calculated as well. For example, office emissions
office_emissions(specify = TRUE, electricity_kwh = 2455.2, water_m3 = 85, heat_kwh = 8764)
#> [1] 2.60238

# Alternatively, more advance emissions can be given with the `raw_fuels()` function.

Shiny App

An interactive calculator using Shiny can be accessed by the shiny_emissions() function. This calculator uses the functions in the carbonr package:

shiny_emissions()

Other online calculators:

Sources:

[1] UK government 2021 report. See https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/990675/2021-ghg-conversion-factors-methodology.pdf https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2021 Note emissions for flights in the code uses values from direct effects only. Radiative forcing = TRUE will give indirect and direct effects. (multiplys by 1.891). See “business travel - air” sheet of gov.uk excel sheet linked above.

[2] Radiative forcing as 1.891 is from www.carbonfund.org

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.