This is an R Markdown document. To explore data and perform analysis according to desired questions or problems.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
##Reading data into R
library(readxl)
store<-read_excel("d:/Superstore.xlsx")
View(store)
Extracting year from given data and adding a column in data
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
salescount<-store %>% group_by(year) %>% summarise(count=sum(Sales))
library(ggplot2)
ggplot(salescount,aes(x=year))+geom_bar(aes(fill=count))
## histogram plot 2. Generate a histogram to display total order quantity and thier frequenies.
hist(store$`Order Quantity`)
## summarised table
summarized table to display year wise sales with order prioirty.
z<-store %>% group_by(year,`Order Priority`) %>% summarise(total_sales=sum(Sales))
View(z)
summarized table and display order priority wise profits.
p<-store %>% group_by(`Order Priority`) %>% summarise(profits=sum(Profit))
View(p)
prof<-store %>% group_by(`Order Priority`) %>% top_n(2,Profit) %>% select(`Order Priority`,Profit)
View(prof)
barplot to display ship mode totals year wise.
ggplot(store,aes(x=year))+geom_bar(aes(fill=`Ship Mode`))
To display year wise ship mode count
shipmode<-store %>% group_by(year,`Ship Mode`) %>% summarise(count=n())
View(shipmode)
fivenum(store$Profit)
## [1] -14140.702 -83.315 -1.500 162.748 27220.690
fivenum(store$Discount)
## [1] 0.00 0.02 0.05 0.08 0.25
summary(store$`Unit Price`)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.99 6.48 20.99 89.35 85.99 6783.02
summary(store$Discount)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00000 0.02000 0.05000 0.04967 0.08000 0.25000
In summary of unit prices mean > median ,we can conclude that unit prices follows right skewed distribution. In summary of Discount mean < median ,we can conclude that Discount follows left skewed distribution.
profitable<-store %>% group_by(`Product Category`) %>% summarise(total_profit=sum(Profit))
View(profitable)
From summarised table we can get the maximum of profits and that is TECHNOLOGIES. Technology product category products are earning maximum profits out of all.
avg_shippingcost<-store %>% group_by(`Ship Mode`) %>% summarise(avg_cost=mean(`Shipping Cost`))
View(avg_shippingcost)
From above table, we can say average shipping cost of delivery truck is more than other shipping modes.It spends 45 rs on an average for one product shipment.
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.