Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Vignettes #51

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
125 changes: 125 additions & 0 deletions vignettes/Clinical_emissions.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: "Clinical Emissions Vignette"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Clinical Emissions Vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

## Calculating Clinical Theatre Emissions

This vignette provides an overview of the `clinical_theatre_emissions` function, guiding users through calculating CO₂-equivalent emissions for various clinical resources in an operating theatre, such as clinical waste, utilities, and materials. This function is designed to offer flexibility for different units and waste types, making it adaptable to various clinical settings.

### Overview of Parameters

The `clinical_theatre_emissions` function includes a wide range of parameters to capture emissions across clinical activities. Here’s a breakdown of the main categories:

- **Clinical Waste**: Accounts for wet clinical waste typically incinerated in a clinical setting. The input can be in kilograms or tonnes to ensure flexibility for different data sources.
- **Anaesthetic Gases**: Emissions from various gases commonly used in surgical procedures, such as desflurane, sevoflurane, and nitrous oxide (N₂O).
- **Utilities**: Includes water usage (in cubic meters or million liters), electricity (kWh), and heating (kWh). Each utility parameter offers options to adjust for transmission and distribution losses (TD) and well-to-tank (WTT) factors to capture indirect emissions.
- **Materials**: Includes emissions from material waste, including glass, paper, and plastic. This category allows for waste disposal types, such as recycling or landfill, to assess the environmental impact of different disposal methods.

## Examples

The following examples demonstrate how to use the `clinical_theatre_emissions` function in different scenarios.

### Load the Package

To use this function, first load the required package:

```{r}
# Load necessary packages for this vignette
library(carbonr)
library(dplyr)
```

### Example 1: Basic Calculation with Default Values

In this example, we calculate emissions for clinical waste, water supply, electricity, and heat with default values. This example is useful for a straightforward scenario without specific anaesthetic gases or waste types.

In this calculation, `wet_clinical_waste` is provided in kilograms (150 kg). We use cubic metres as the unit for `water_supply`, and the electricity and heating inputs are provided in kWh. This setup calculates the emissions from basic clinical waste and utility usage.

```{r example_data, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
# Create an example data frame, called example_data.
example_data <- data.frame(
wet_clinical_waste = 150, # 150 kg of wet clinical waste
water_supply = 100, # 100 cubic meters of water
electricity_kWh = 500, # 500 kWh of electricity
heat_kWh = 200 # 200 kWh of heating
)
example_data
```

```{r, message = FALSE, warning = FALSE, echo = FALSE}
example_data <- data.frame(
wet_clinical_waste = 150, # 150 kg of wet clinical waste
water_supply = 100, # 100 cubic meters of water
electricity_kWh = 500, # 500 kWh of electricity
heat_kWh = 200 # 200 kWh of heating
)
example_data %>% knitr::kable()
```
Comment on lines +43 to +62
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PhyllisMuniu I'm here running it "twice". This is for formatting reasons. The first time, I'm giving it to display the code.
The second time, I'm giving it to run the code, and put it into a nice table (knitr::kable)


```{r emissions, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
# We can call our example_data frame to get the values
example_data %>%
dplyr::mutate(emissions = clinical_theatre_emissions(
wet_clinical_waste = wet_clinical_waste,
wet_clinical_waste_unit = "kg",
electricity_kWh = electricity_kWh,
heat_kWh = heat_kWh,
water_supply = water_supply,
water_unit = "cubic metres")
)
```

```{r, message = FALSE, warning = FALSE, echo = FALSE}
example_data %>%
dplyr::mutate(emissions = clinical_theatre_emissions(
wet_clinical_waste = wet_clinical_waste,
wet_clinical_waste_unit = "kg",
electricity_kWh = electricity_kWh,
heat_kWh = heat_kWh,
water_supply = water_supply,
water_unit = "cubic metres")) %>%
knitr::kable()
```

### Example 2: Including Anaesthetic Gases

This example includes emissions from anaesthetic gases along with clinical waste, electricity, heating, and water. Adding anaesthetic gases can give a more comprehensive view of the emissions, particularly in settings with significant use of these gases.

This example demonstrates emissions including anaesthetic gases - specifically, desflurane, sevoflurane, and N₂O. These gases have high greenhouse gas potential, so their inclusion can significantly affect total emissions in a clinical setting where they are frequently used.

```{r emissions_with_gases, eval=FALSE}
# We do not have to call from a data frame. For example, here we just input the values
emissions_with_gases <- clinical_theatre_emissions(
wet_clinical_waste = 150, # Wet clinical waste in kg
wet_clinical_waste_unit = "kg",
desflurane = 10, # 10 liters of desflurane
sevoflurane = 5, # 5 liters of sevoflurane
N2O = 100, # 100 liters of N₂O
electricity_kWh = 500,
heat_kWh = 200,
water_supply = 100
)
print(emissions_with_gases)
```

### Example 3: Reducing Waste and Emissions

This example shows how reduced resource usage affects emissions. Reductions in clinical waste, water, electricity, and heat are used to model a more sustainable scenario.

In this, `wet_clinical_waste` is significantly reduced to 0.1 tonnes, demonstrating the effect of minimised clinical waste on emissions. This example also shows the impact of reduced utility usage, providing insights into how efficient resource management can decrease the environmental footprint of clinical operations.

```{r reduced_emissions, eval=FALSE}
reduced_emissions <- clinical_theatre_emissions(
wet_clinical_waste = 0.1, # Clinical waste in tonnes
wet_clinical_waste_unit = "tonnes",
electricity_kWh = 300, # Reduced electricity
heat_kWh = 100, # Reduced heating
water_supply = 50 # Reduced water
)
print(reduced_emissions)
```
168 changes: 168 additions & 0 deletions vignettes/Company_emissions.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
title: "Company Emissions"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Company Emissions}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

## Company Emissions with carbonr
This vignette demonstrates a step-by-step process for calculating and combining different types of company emissions, including office emissions, hotel emissions, and travel emissions, using various functions to track and calculate the carbon footprint associated with different company activities.


### Introduction
Understanding the overall carbon footprint of a company is important to meet company sustainability goals. This vignette details the process for calculating emissions from company office operations, employee travel (e.g., car, air, ferry, rail), and hotel accommodations, ultimately allowing the organisation to identify high-emission areas and take action to reduce them.

To begin, install and load the necessary packages.
```{r}
library(carbonr)
library(dplyr)
library(purrr)
```

## Office Emissions:
Start by calculating emissions from office-related activities such as energy consumption, waste production, and equipment usage.

### Example Office Emission Calculation
For calculating office emissions, use `office_emissions()` function from the `carbonr` package. This function requires input values for energy use (e.g., electricity and heating).

```{r, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
carbonr::office_emissions(specify = TRUE,
electricity_kWh = 200,
water_supply = 100,
water_unit = "cubic metres",
water_trt = FALSE
)
```

### Hotel Emissions:
We calculate emissions related to hotel stays for business trips using `hotel_emissions()`. This function calculates the emissions based on the number of nights, room type, and occupancy rate.

### Example Hotel Emission Calculation
```{r, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
carbonr::hotel_emissions(location = "Fiji", nights = 2, rooms = 1)
```

## Travel-related Emissions

### Airplane Emissions
Using the `carbonr` package, we can calculate emissions for a flight between Nairobi and Kisumu by first finding the airport codes.

```{r, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
airport_finder(name = "Nairobi")
```

```{r, message = FALSE, warning = FALSE, echo = FALSE}
airport_finder(name = "Nairobi") %>%
knitr::kable()
```

```{r find_airport_kisumu, eval=FALSE, message=FALSE, warning=FALSE}
airport_finder(name = "Kisumu")
```

```{r, message = FALSE, warning = FALSE, echo = FALSE}
airport_finder(name = "Kisumu") %>%
knitr::kable()
```

With the IATA codes (`"NBO"` for Nairobi and `"KIS"` for Kisumu), we can calculate emissions

```{r airplane_emissions_chunk, message=FALSE, warning=FALSE}
airplane_emissions("NBO", "KIS")
```

### Ferry Emissions
To estimate emissions for ferry travel, for instance, from Shimoni to Giohar, we start by locating seaport codes:

```{r, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
seaport_finder(city = "Shimoni")
```

```{r, message = FALSE, warning = FALSE, echo = FALSE}
seaport_finder(city = "Shimoni") %>%
knitr::kable()
```

```{r, eval=FALSE, message=FALSE, warning=FALSE}
seaport_finder(city = "Giohar")
```

```{r, message = FALSE, warning = FALSE, echo = FALSE}
seaport_finder(city = "Giohar") %>%
knitr::kable()
```

With codes `"SMN"` for Shimoni and `"GHR"` for Giohar we can now calculate the ferry emissions:

```{r ferry_example, message=FALSE, warning=FALSE}
ferry_emissions("SMN", "GHR", round_trip = TRUE)
```

### Train Emissions
For the UK we can calculate emissions for a train journey. Like with `airplane_emissions()` and `ferry_emissions()`, the distances are calculated using the Haversine formula - this is calculated as the crow flies. As before, we first find the stations. As always, for a more accurate estimation we can include via points:

To calculate emissions for a train journey from Bristol Temple Meads to Edinburgh Waverley, via Birmingham New Street. We can use a data frame and `purrr::map()` to read through the data easier.

```{r, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
multiple_ind <- tibble::tribble(~ID, ~station,
"From", "Bristol",
"To", "Edinburgh",
"Via", "Birmingham")
purrr::map(.x = multiple_ind$station, .f = ~rail_finder(.x)) %>%
dplyr::bind_rows()
```
```{r, message = FALSE, warning = FALSE, echo=FALSE}
multiple_ind <- tibble::tribble(~ID, ~station,
"From", "Bristol",
"To", "Edinburgh",
"Via", "Birmingham")
purrr::map(.x = multiple_ind$station, .f = ~rail_finder(.x)) %>%
dplyr::bind_rows() %>%
knitr::kable()
```

Then we can estimate the overall tCO2e emissions for the journey:
```{r, message = FALSE, warning = FALSE}
rail_emissions(from = "Bristol Temple Meads", to = "Edinburgh", via = "Birmingham New Street")
```

## Aggregating Emissions for Multiple Individuals
Using data frames and mapping functions, we can calculate combined emissions for multiple travel types.

```{r, message = FALSE, warning = FALSE, eval=FALSE, include=TRUE}
multiple_ind <- tibble::tribble(
~ID, ~rail_from, ~rail_to, ~air_from, ~air_to, ~air_via,
"Clint", "Bristol Temple Meads", "Paddington", "LHR", "KIS", "NBO",
"Zara", "Bristol Temple Meads", "Paddington", "LHR", "LAX", "ORL"
)

multiple_ind %>%
rowwise() %>%
mutate(
plane_emissions = carbonr::airplane_emissions(air_from, air_to, air_via),
train_emissions = carbonr::rail_emissions(rail_from, rail_to)
) %>%
mutate(total_emissions = plane_emissions + train_emissions)
```

```{r, message = FALSE, warning = FALSE, echo=FALSE}
multiple_ind <- tibble::tribble(
~ID, ~rail_from, ~rail_to, ~air_from, ~air_to, ~air_via,
"Clint", "Bristol Temple Meads", "Paddington", "LHR", "KIS", "NBO",
"Zara", "Bristol Temple Meads", "Paddington", "LHR", "LAX", "ORL"
)

multiple_ind %>%
rowwise() %>%
mutate(
plane_emissions = carbonr::airplane_emissions(air_from, air_to, air_via),
train_emissions = carbonr::rail_emissions(rail_from, rail_to)
) %>%
mutate(total_emissions = plane_emissions + train_emissions) %>%
knitr::kable()
```

## References:
Emission factors are based on the UK Government’s 2024 greenhouse gas reporting conversion factors: [Greenhouse Gas Conversion Factors](https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2024).
Loading