#1. Using the McDonals.xlsx dataset, create scatter plot that depicts the relationship between
#Average Frequency and Income. Note that this is the frequency in which a person visits
#McDonalds per week.
# install.packages("readxl")
# install.packages("ggplot2")
library(readxl)
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
# Read the Excel file
mc_data <- read_excel("Mcdonalds.xlsx")
# Scatter plot
ggplot(mc_data, aes(x = Income, y = `Average Frequency`, color = `Average Frequency`)) +
geom_point(size = 3) +
scale_color_gradient(low = "blue", high = "red") +
labs(title = "Analyzing the Business Impact of Increased McDonald's Visits Among the 30-80 Income Group",
x = "Income",
y = "Average Frequency",
color = "Frequency") +
theme_minimal()

#2. Using the Dow.xlsx dataset, create a line chart that depicts the average return (y axis) by
#month (x axis). The grade is heavily weighted on the one sentence takeaway.
# Read the Excel file
dow_data <- read_excel("Dow-1.xlsx")
# Line chart
ggplot(dow_data, aes(x = Month, y = Return)) +
geom_line() +
labs(title = "Average Monthly Returns - Dow Dataset",
x = "Month",
y = "Average Return")

###Plotly
plot_ly(data = dow_data, x = ~Month, y = ~Return, type = 'scatter', mode = 'lines',
hoverinfo = "x+y+text", text = ~paste("Month: ", Month, "<br>Return: ", Return)) %>%
layout(title = "Average Monthly Returns - Dow Dataset",
xaxis = list(title = "Month"),
yaxis = list(title = "Average Return"))