library(readr)
ad=read_csv("C:/Users/USER/Downloads/UrbanMart_Retail.csv")
## Rows: 300 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): City, Month, Category, Channel
## dbl (4): Footfall, Total_Sales, Customer_Satisfaction, Returns
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ad
## # A tibble: 300 × 8
## City Month Category Channel Footfall Total_Sales Customer_Satisfaction
## <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
## 1 Bangalore Jan Clothing In-Sto… 228 94075 4
## 2 Delhi Apr Clothing In-Sto… 345 154077 3
## 3 Bangalore Aug Groceries Online 79 35585 2
## 4 Bangalore Dec Electroni… In-Sto… 199 166867 2
## 5 Mumbai Aug Electroni… Online 88 58327 2
## 6 Bangalore Mar Electroni… Online 42 27929 2
## 7 Bangalore Jun Clothing In-Sto… 375 213421 5
## 8 Delhi Feb Groceries In-Sto… 188 58830 4
## 9 Chennai Aug Clothing Online 28 11421 2
## 10 Bangalore Jun Clothing In-Sto… 324 193863 1
## # ℹ 290 more rows
## # ℹ 1 more variable: Returns <dbl>
#1
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
library(ggplot2)
plot1<-ad%>%
group_by(City)%>%
summarise(total=sum(Total_Sales))%>%
ggplot(aes(City,total))+
geom_col(fill="pink",color="lavender")+
geom_text(aes(label = total),vjust=-0.5,color="red")
print(plot1)

#2
plot2=ad%>%
group_by(Month)%>%
summarise(Sales=sum(Total_Sales))%>%
ggplot(aes(Month,Sales,group = 1))+
geom_line()+
geom_text(aes(label = Sales),vjust=-0.5)
print(plot2)

#3
plot3=ad%>%
group_by(Category)%>%
summarise(sales=sum(Total_Sales))%>%
ggplot(aes("",sales,fill = Category))+
geom_col()+
coord_polar("y")+
geom_text(aes(label = sales),position = position_stack(vjust = 0.5))
print(plot3)

#4
plot4=mean(ad$Footfall)
ggplot(ad,aes(Footfall))+
geom_histogram(binwidth = 160,color="red")+
stat_bin(binwidth = 160,geom="text",aes(label=..count..),vjust=-0.5)
## Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(count)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

print(plot4)
## [1] 159.4633
#5
plot5=ggplot(ad,aes(Footfall,Total_Sales))+
geom_point(color="lightgreen")
print(plot5)

#6
plot6=ggplot(ad,aes(City,Total_Sales))+
geom_boxplot()+
stat_summary(fun = mean,geom = "text",aes(label=round(..y..,0),vjust=-0.5))
print(plot6)

#7
plot7=ad%>%
group_by(City,Channel)%>%
summarise(total=sum(Total_Sales))%>%
ggplot(aes(City,total,fill = Channel))+
geom_col()+
geom_text(aes(label=total),vjust=-0.5)
## `summarise()` has grouped output by 'City'. You can override using the
## `.groups` argument.
print(plot7)

#8
plot8=ad%>%
group_by(City,Category)%>%
summarise(cs=mean(Customer_Satisfaction))%>%
ggplot(aes(City,Category,fill = cs))+
geom_tile()+
geom_text(aes(label = round(cs,1)))
## `summarise()` has grouped output by 'City'. You can override using the
## `.groups` argument.
print(plot8)
