relative_gti | R Documentation |
Calculate and plot the relative growth to index (GTI) over time
relative_gti(
data = data,
time = time,
date_format = c("%d/%m/%Y"),
name = theatre,
val = emissions,
gti_by = c("default", "month", "year")
)
data |
The data frame containing the data. |
time |
The variable representing the time dimension. |
date_format |
The date format for the time variable (optional, default: c("%d/%m/%Y")). |
name |
The variable representing the grouping variable. |
val |
The variable representing the value. |
gti_by |
The grouping type for calculating the GTI ("default", "month", "year"). |
A ggplot2 object showing the relative GTI (Growth to Index) over time.
# Example dataset
emission_data <- data.frame(
theatre = c("Theatre A", "Theatre A", "Theatre B", "Theatre B", "Theatre A", "Theatre B"),
emissions = c(200, 250, 150, 180, 300, 220),
date = c("01/01/2023", "01/02/2023", "01/01/2023", "01/02/2023", "01/03/2023", "01/03/2023")
)
# Using the relative_gti function
relative_gti_plot <- relative_gti(
data = emission_data,
time = date,
date_format = "%d/%m/%Y", # Date format used in the dataset
name = theatre,
val = emissions,
gti_by = "default" # Calculating based on default time period
)
# Plot the relative GTI
print(relative_gti_plot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.