This function creates a bar chart for visualizing data such as income, expenses, and savings. It supports a colorblind-friendly mode by changing the color palette. The function is primarily designed for use in a Shiny application to display financial data.
Arguments
- data
A data frame containing the data to be plotted. Expected to contain at least two columns: 'category' for the data categories and 'amount' for the values.
- colorblind_switch
Logical flag indicating whether to use a colorblind-friendly color palette.
Author
Group C composed of Marc Bourleau, Eleonore Gillain, Khrystyna Khmilovska and Konstantinos Kourlimpinis.
Examples
# Example usage:
data <- data.frame(
category = c("Income", "Expenses", "Savings"),
amount = c(1000, 750, 250)
)
# Example for a colorblind-friendly chart
plot <- generate_bar_chart(data, TRUE)
# In a Shiny app, use renderPlotly() to display this plot