Retail<-data.frame(
Bill_ID= c(501,502,503,504,505,506),
customerName=c("Aman","Riya","Karan","Neha","Rohit","Simran"),
Gender=factor(c("Male","Female","Male","Female","Male","Female")),
membership= factor(c("Gold","Silver","Gold","None","Silver","Gold")),
category=factor(c("Grocery","Electronics","Clothing","Grocery","Electronics","Clothing")),
Quantity=c(10,1,3,8,2,5),
CostPrice=c(50,20000,800,60,18000,700),
SellingPrice=c(70,25000,1000,80,22000,900),
Discount=c(100,2000,150,50,500,300),
DeliveryType=factor(c("Home","Store","Home","Store","Home","Home"))
)
Retail
## Bill_ID customerName Gender membership category Quantity CostPrice
## 1 501 Aman Male Gold Grocery 10 50
## 2 502 Riya Female Silver Electronics 1 20000
## 3 503 Karan Male Gold Clothing 3 800
## 4 504 Neha Female None Grocery 8 60
## 5 505 Rohit Male Silver Electronics 2 18000
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType
## 1 70 100 Home
## 2 25000 2000 Store
## 3 1000 150 Home
## 4 80 50 Store
## 5 22000 500 Home
## 6 900 300 Home
Retail$GrossRevenue<-Retail$Quantity*Retail$SellingPrice
Retail
## Bill_ID customerName Gender membership category Quantity CostPrice
## 1 501 Aman Male Gold Grocery 10 50
## 2 502 Riya Female Silver Electronics 1 20000
## 3 503 Karan Male Gold Clothing 3 800
## 4 504 Neha Female None Grocery 8 60
## 5 505 Rohit Male Silver Electronics 2 18000
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType GrossRevenue
## 1 70 100 Home 700
## 2 25000 2000 Store 25000
## 3 1000 150 Home 3000
## 4 80 50 Store 640
## 5 22000 500 Home 44000
## 6 900 300 Home 4500
Retail$TotalCost<-Retail$Quantity*Retail$CostPrice
Retail
## Bill_ID customerName Gender membership category Quantity CostPrice
## 1 501 Aman Male Gold Grocery 10 50
## 2 502 Riya Female Silver Electronics 1 20000
## 3 503 Karan Male Gold Clothing 3 800
## 4 504 Neha Female None Grocery 8 60
## 5 505 Rohit Male Silver Electronics 2 18000
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType GrossRevenue TotalCost
## 1 70 100 Home 700 500
## 2 25000 2000 Store 25000 20000
## 3 1000 150 Home 3000 2400
## 4 80 50 Store 640 480
## 5 22000 500 Home 44000 36000
## 6 900 300 Home 4500 3500
Retail$NetRevenue<-Retail$GrossRevenue-Retail$Discount
Retail
## Bill_ID customerName Gender membership category Quantity CostPrice
## 1 501 Aman Male Gold Grocery 10 50
## 2 502 Riya Female Silver Electronics 1 20000
## 3 503 Karan Male Gold Clothing 3 800
## 4 504 Neha Female None Grocery 8 60
## 5 505 Rohit Male Silver Electronics 2 18000
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType GrossRevenue TotalCost NetRevenue
## 1 70 100 Home 700 500 600
## 2 25000 2000 Store 25000 20000 23000
## 3 1000 150 Home 3000 2400 2850
## 4 80 50 Store 640 480 590
## 5 22000 500 Home 44000 36000 43500
## 6 900 300 Home 4500 3500 4200
Retail$Profit<-Retail$NetRevenue-Retail$TotalCost
Retail
## Bill_ID customerName Gender membership category Quantity CostPrice
## 1 501 Aman Male Gold Grocery 10 50
## 2 502 Riya Female Silver Electronics 1 20000
## 3 503 Karan Male Gold Clothing 3 800
## 4 504 Neha Female None Grocery 8 60
## 5 505 Rohit Male Silver Electronics 2 18000
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType GrossRevenue TotalCost NetRevenue Profit
## 1 70 100 Home 700 500 600 100
## 2 25000 2000 Store 25000 20000 23000 3000
## 3 1000 150 Home 3000 2400 2850 450
## 4 80 50 Store 640 480 590 110
## 5 22000 500 Home 44000 36000 43500 7500
## 6 900 300 Home 4500 3500 4200 700
subset(Retail,membership=="Gold" & DeliveryType=="Home" & Profit>500)
## Bill_ID customerName Gender membership category Quantity CostPrice
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType GrossRevenue TotalCost NetRevenue Profit
## 6 900 300 Home 4500 3500 4200 700
subset(Retail,membership=="Gold" | NetRevenue>20000)
## Bill_ID customerName Gender membership category Quantity CostPrice
## 1 501 Aman Male Gold Grocery 10 50
## 2 502 Riya Female Silver Electronics 1 20000
## 3 503 Karan Male Gold Clothing 3 800
## 5 505 Rohit Male Silver Electronics 2 18000
## 6 506 Simran Female Gold Clothing 5 700
## SellingPrice Discount DeliveryType GrossRevenue TotalCost NetRevenue Profit
## 1 70 100 Home 700 500 600 100
## 2 25000 2000 Store 25000 20000 23000 3000
## 3 1000 150 Home 3000 2400 2850 450
## 5 22000 500 Home 44000 36000 43500 7500
## 6 900 300 Home 4500 3500 4200 700