# loading data
Store8<- read.csv(file="C:/develop/OneDrive - MSFT/Documents/MIS410/Shore 8 walmart.csv")

1 1. Which dates have the maximum and minimum sales for your store?

ANS

# Load necessary library
library(dplyr)

# creating max salte
max_sales_date <- Store8 %>%
  filter(Weekly_Sales == max(Weekly_Sales)) %>%
  select(Date, Weekly_Sales)

# creating min salte
min_sales_date <- Store8 %>%
  filter(Weekly_Sales == min(Weekly_Sales)) %>%
  select(Date,Weekly_Sales)

# view max & min
max_sales_date
##         Date Weekly_Sales
## 1 24-12-2010      1511641
min_sales_date
##         Date Weekly_Sales
## 1 26-03-2010     772539.1

2 2. Find the mean and standard deviation of weekly sales and comment on the results.

ANS

  • The mean weekly sales of $908,749.52 indicates the average amount of sales generated per week. This value provides a central tendency measure for the weekly sales data.

  • The standard deviation of $106,280.83 indicates the extent of variability or dispersion in the weekly sales data around the mean. A higher standard deviation suggests that the weekly sales values are more spread out from the mean, whereas a lower standard deviation suggests that the values are closer to the mean.

  • In this case, a standard deviation of $106,280.83 implies that the weekly sales data has a notable degree of variability around the mean. This variability could be due to various factors such as seasonality, promotions, or external economic factors affecting sales.

mean_sales <- mean(Store8$Weekly_Sales)
sd_sales <- sd(Store8$Weekly_Sales)

# Print the results
print(paste("Mean of Weekly Sales: ", round(mean_sales, 2)))
## [1] "Mean of Weekly Sales:  908749.52"
print(paste("Standard Deviation of Weekly Sales: ", round(sd_sales, 2)))
## [1] "Standard Deviation of Weekly Sales:  106280.83"

3 3. Construct a boxplot and describe the distribution of weekly sales.

ANS

# Load necessary library
library(ggplot2)

# Check the first few rows of the data to ensure it's read correctly
head(Store8)
##   Store       Date Weekly_Sales Holiday_Flag Temperature Fuel_Price      CPI
## 1     8   5/2/2010    1004137.1            0       34.14      2.572 214.4715
## 2     8  12/2/2010     994801.4            1       33.34      2.548 214.6214
## 3     8 19-02-2010     963960.4            0       39.10      2.514 214.6665
## 4     8 26-02-2010     847592.1            0       37.91      2.561 214.6941
## 5     8   5/3/2010     881503.9            0       45.64      2.625 214.7217
## 6     8  12/3/2010     860336.2            0       49.76      2.667 214.7492
##   Unemployment
## 1        6.299
## 2        6.299
## 3        6.299
## 4        6.299
## 5        6.299
## 6        6.299
# Create a boxplot of the Weekly_Sales column
boxplot(Store8$Weekly_Sales, main = "Boxplot of Weekly Sales", ylab = "Weekly Sales")

# Summarize the distribution of Weekly Sales
summary(Store8$Weekly_Sales)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  772539  855905  893400  908750  929021 1511641

4 4. Draw a scatterplot between weekly sales and temperatures, and comment on the relationship

ANS

#scatterplot
ggplot(Store8, aes(x = Temperature, y = Weekly_Sales)) +
  geom_point(size = 2) +
  labs(title = "Scatterplot of Weekly Sales vs Temperature", x = "Temperature", y = "Weekly Sales")

5 5. Draw a line plot for weekly sales

ANS

# Line plot
ggplot(Store8, aes(x = Date, y = Weekly_Sales, group = 1)) +
  geom_line() +
  labs(title = "Line Plot of Weekly Sales Over Time", x = "Date", y = "Weekly Sales")