-
Notifications
You must be signed in to change notification settings - Fork 0
/
guided_project.R
54 lines (53 loc) · 4.08 KB
/
guided_project.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
store<-read.csv("MY DEPARTMENTAL STORE.csv")
store1 <- filter(store, PRODUCT_TYPE=="foodgrains&spices")
store1<-Filter(store, PRODUCT_TYPE=="foodgrain&spices")
View(store1)
View(store)
library("dplyr")
library("ggplot2")
store1<- filter(store, COMPANY %in% c("S", "M"))
View(store1)
View(store2)
store2<-select(store, SELLING_PRICE, COMPANY)
store1<-select(store, c(2,5))
View(store1)
store1<-select(store,2:5)
View(store1)
store1<-select(store,starts_with("P"))
store1<-select(store, ends_with("E"))
View(store1)
store2<-mutate(store1, PROFIT_PERCENT=PROFIT/COST_PRICE*100)
store1<-mutate(store, PROFIT=SELLING_PRICE-COST_PRICE)
store2<-mutate(store1, PROFIT_PERCENT=PROFIT/COST_PRICE*100)
store3<-mutate(store1, NET_PROFIT=PROFIT*QUANTITY_DEMANDED)
View(store3)
write.table(store3, file="FINAL DEPARTMENTAL STORE.csv", sep=",")
store<-read.csv("FINAL DEPARTMENTAL STORE.csv")
store1<-arrange(store,)
View(store1)
store1<-arrange(store, QUANTITY_DEMANDED)
store1<-arrange(store, desc(SELLING_PRICE))
summarise(store, AVERAGE=mean(PROFIT, na.rm=TRUE))
SUM_NET_PROFIT<-summarise(store1, SUM=sum(NET_PROFIT, na.rm=TRUE))
summarise(store, MINIMUM=min(PROFIT, na.rm="TRUE"))
summarise(store, MEDIAN=median(PROFIT, na.rm="TRUE"))
store %>%filter(COST_PRICE>10) %>%
ggplot(aes(x=COMPANY, y=NET_PROFIT, color=PRODUCT_CATEGORY))+geom_point()
store %>% filter(PRODUCT_TYPE == 'hygiene') %>% ggplot(aes(x='COMPANY', y='NET_PROFIT')) + geom_point()
store %>% filter(PRODUCT_TYPE == 'hygiene') %>% ggplot(aes(x='QUANTITY_DEMANDED', y='PROFIT')) + geom_point()
store %>% filter(PRODUCT_TYPE == 'hygiene') %>% ggplot(aes(x='QUANTITY_DEMANDED', y='PROFIT', color='PRODUCT_CATEGORY')) + geom_point()
store %>% filter(PRODUCT_TYPE == 'beauty_products') %>% ggplot(aes(x='QUANTITY_DEMANDED', y='PROFIT', color='PRODUCT_CATEGORY'))+geom_point()
store %>% filter(PRODUCT_TYPE == 'beauty_products') %>% ggplot(aes(x='QUANTITY_DEMANDED', y='PROFIT', color='PRODUCT_CATEGORY'))+geom_point()
store %>% filter(PRODUCT_TYPE == 'beauty products') %>% ggplot(aes(x='QUANTITY_DEMANDED', y='PROFIT', color='PRODUCT_CATEGORY'))+geom_point()
store %>% group_by(PRODUCT_TYPE) %>% summarise(AVERAGE_QUANTITY=mean(QUANTITY_DEMANDED)) %>% ggplot(aes(x=PRODUCT_TYPE, y=AVERAGE_QUANTITY)) + geom_col(width=0.6, fill='light blue') + theme(text=element_text(size = 9))
store %>% group_by(COMPANY) %>% summarise(AVERAGE_NET_PROFIT=mean(NET_PROFIT)) %>% ggplot(aes(x=COMPANY, y=AVERAGE_NET_PROFIT)) + geom_col(width=0.6, fill='light blue') + theme(text=element_text(size=10))
store2 %>% group_by(PRODUCT_TYPE) %>% summarise(AVERAGE_PROFIT_PERCENT=mean(PROFIT_PERCENT)) %>% ggplot(aes(x=PRODUCT_TYPE, y=AVERAGE_PROFIT_PERCENT)) + geom_col(width=0.6, fill='pink') + theme(text=element_text(size=9))
store %>% group_by(QUANTITY_DEMANDED) %>% summarise(AVERAGE_SELLING_PRICE=mean(SELLING_PRICE, nam.rm=TRUE)) %>% ggplot(aes(x=QUANTITY_DEMANDED, y=AVERAGE_SELLING_PRICE, group=1)) + geom_line(color='green')
store %>% group_by(PRODUCT_CATEGORY) %>% summarise(AVERAGE_QUANTITY = mean(QUANTITY_DEMANDED, na.rm=TRUE)) %>% ggplot(aes(x=PRODUCT_CATEGORY, y=AVERAGE_QUANTITY, group=1)) + geom_line(color='pink')+theme(text=element_text(size=4.5))
net_profit_filter_data <- store %>% filter(NET_PROFIT > 100)
net_profit_filter_data %>% group_by(PRODUCT_TYPE) %>% summarise(AVERAGE_NET_PROFIT=mean(NET_PROFIT)) %>% ggplot(aes(x=PRODUCT_TYPE, y=AVERAGE_NET_PROFIT, group=1)) + geom_line(color='green') + theme(text = element_text(size=5))
store %>% filter(NET_PROFIT > 100) %>% group_by(PRODUCT_TYPE) %>% summarise(AVERAGE_NET_PROFIT=mean(NET_PROFIT)) %>% ggplot(aes(x=PRODUCT_TYPE, y=AVERAGE_NET_PROFIT, group=1)) + geom_line(color='green') + theme(text = element_text(size=5))
store <- read.csv("FINAL DEPARTMENTAL STORE.csv")
store2 %>% ggplot(aes(x=PROFIT_PERCENT, fill=PRODUCT_CATEGORY)) + geom_histogram(binwidth=30)
store %>% filter(PRODUCT_TYPE == 'snacks') %>% ggplot(aes(x=QUANTITY_DEMANDED, fill=PRODUCT_CATEGORY)) + geom_histogram(binwidth=30)
store %>% filter(PRODUCT_TYPE == 'snacks') %>% ggplot(aex(x=SELLING_PRICE, fill=PRODUCT_CATEGORY)) + geom_histogram(binwidth=30)