Student Information

πŸ“ Full Name: Dorothy Pierandrri πŸ†” Student ID: 702688145


Task 01: Exploring the Sales Dataset

Instructions:
- Load the necessary packages: ggplot2, dplyr.
- Load the Sales.csv dataset.
- Retrieve the number of columns and rows in the dataset.
- Use str() to examine the structure of the dataset.
- Use glimpse() for a quick overview of the dataset.

πŸ“Œ Need help? Refer to Slides 4-5 of Lecture 12 for guidance.

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
Sales <- read.csv("Sales.csv")
ncol(Sales)
## [1] 3
nrow(Sales)
## [1] 24
str(Sales)
## 'data.frame':    24 obs. of  3 variables:
##  $ Year : chr  "Y2021" "Y2021" "Y2021" "Y2021" ...
##  $ Month: int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Sales: int  11110 18816 15307 11491 15971 16916 15762 15983 14226 12601 ...
glimpse(Sales)
## Rows: 24
## Columns: 3
## $ Year  <chr> "Y2021", "Y2021", "Y2021", "Y2021", "Y2021", "Y2021", "Y2021", "…
## $ Month <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9…
## $ Sales <int> 11110, 18816, 15307, 11491, 15971, 16916, 15762, 15983, 14226, 1…

Task 02: Creating a Sales Comparison Line Graph

Instructions:
- Create a line graph to visualize the relationship between Month and Sales, grouped by Year.
- Modify the line type and color based on the Year variable.
- Adjust the line width to 0.7.
- Add data points, distinguishing years by color and shape.
- Set the point size to 2.
- Label the x-axis as "Months".
- Label the y-axis as "Sales".
- Add a plot title: "Sales Comparison".
- Add a plot subtitle: "Year 2021 & 2022".
- Apply the classic theme to the plot.
- Center-align the title and subtitle.

πŸ“Œ Need help? Refer to Slides 16-17 of Lecture 12 for guidance.

ggplot(data=Sales, aes(x=Month, y= Sales,group=Year )) +
  geom_line(aes(linetype= Year, color= Year), size=2) +
  geom_point(aes(color= Year, shape=Year),size=2) +
  labs (x= "Months" ,y="Sales",
        title = "Sales Comparison",
        subtitle = "Yeard 2021 & 2022") +
  theme_classic() +
  theme(plot.title = element_text(hjust = 0.5),
        plot.subtitle = element_text(hjust = 0.5))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## β„Ή Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Task 03: Saving the Sales Trend Comparison

Instructions:
- Save the line graph created in Task 2 as an image file.
- Name the file β€œSales_Trend_Comparison.jpg”.

πŸ“Œ Need help? Refer to Slide 18 of Lecture 12 for guidance.

#Save the line graph as an image file
ggsave("Sales_Trend_Comparison.jpg")
## Saving 7 x 5 in image

Final Steps: Submitting Your Work

βœ… Save your work.
βœ… Knit your R Notebook as an HTML file.
⚠ Do NOT submit the .Rmd file.

πŸ“₯ Submission on Canvas:

Upload the following two files:

1️⃣ YourFirstName_YourLastName - In-Class Assignment 08.html
2️⃣ Sales_Trend_Comparison.jpg

πŸ“Œ Double-check your files before submitting!