C) Done in the PDF

Redid the visualisation bits
This commit is contained in:
LinlyBoi
2022-01-01 18:15:01 +02:00
parent 2397446d94
commit 92cfb8769e
2 changed files with 14 additions and 7 deletions

21
Data.R
View File

@@ -20,35 +20,42 @@ coul <- brewer.pal(5, "Set2")
#Read spreadsheet file #Read spreadsheet file
grocery_entries <- read.csv(file.choose()) grocery_entries <- read.csv(file.choose())
#Compare cash and credit totals -Sewelam #Compare cash and credit totals -Sewelam
cash_credit <- cbind(grocery_entries[3], grocery_entries[8]) cash_credit <- cbind(grocery_entries[3], grocery_entries[8])
sum_cash <-sum(cash_credit[which(cash_credit$paymentType=='Cash'),1]) sum_cash <-sum(cash_credit[which(cash_credit$paymentType=='Cash'),1])
sum_credit <-sum(cash_credit[which(cash_credit$paymentType=='Credit'),1]) sum_credit <-sum(cash_credit[which(cash_credit$paymentType=='Credit'),1])
CompCashCredit <- c(sum_cash,sum_credit) CompCashCredit <- c(sum_cash,sum_credit)
barplot(CompCashCredit,names.arg = c('Cash','Credit'),horiz = FALSE,col = coul) barplot(CompCashCredit,names.arg = c('Cash','Credit'),horiz = TRUE,col = coul)
#City and Total Spent comparison -Jimmy #City and Total Spent comparison -Jimmy
city_total <- cbind(grocery_entries[3], grocery_entries[7]) city_total <- cbind(grocery_entries[3], grocery_entries[7])
sum_cities<-aggregate(total ~city ,city_total,sum) sum_cities<-aggregate(total ~city ,city_total,sum)
pie(sum_cities$total sum_citiesOrdered <- sum_cities[order(sum_cities$total),]
,col = coul barplot(height = sum_citiesOrdered$total,names.arg = sum_citiesOrdered$city,col = coul,las=2)
,labels = sum_cities$city
,main = "Cities and total spent")
#Compare between ages and their total spent (Youssri) #Compare between ages and their total spent (Youssri)
age <- cbind(grocery_entries[6] , grocery_entries[3]) age <- cbind(grocery_entries[6] , grocery_entries[3])
sum_ages <- aggregate(total ~ age,age,sum) sum_ages <- aggregate(total ~ age,age,sum)
plot(sum_ages) pie(sum_ages$total,col = coul,labels = sum_ages$age,main = "Ages and total spent")
#Distribution of spending - Abdo #Distribution of spending - Abdo
plot(grocery_entries$total, col = coul,type = "l", main = "spending") plot(grocery_entries$total, col = coul,type = "l", main = "spending")
#All in one dashboard
pdf(file = "graphs.pdf")
plot(grocery_entries$total, col = coul,type = "l", main = "spending")
pie(sum_ages$total,col = coul,labels = sum_ages$age,main = "Ages and total spent")
barplot(height = sum_citiesOrdered$total,names.arg = sum_citiesOrdered$city,col = coul,las=2)
barplot(CompCashCredit,names.arg = c('Cash','Credit'),horiz = TRUE,col = coul)
dev.off()
#kmeans --Yousri #kmeans --Yousri
name_total_age<-cbind(grocery_entries[5],grocery_entries[3],grocery_entries[6]) name_total_age<-cbind(grocery_entries[5],grocery_entries[3],grocery_entries[6])
@@ -59,7 +66,7 @@ final_result<-cbind(name_total_age,result$cluster)
#Association Rules --Sewelam #Association Rules --Sewelam
clean_data <- grocery_entries[,-5] clean_data <- grocery_entries[,-5] #remove names
minsup <- as.numeric(readline("Enter minimum support: ")) minsup <- as.numeric(readline("Enter minimum support: "))
minconf <- as.numeric(readline("Enter minimum confidence: ")) minconf <- as.numeric(readline("Enter minimum confidence: "))
asoc_rules <- apriori(clean_data,parameter = list(supp = minsup,conf = minconf)) asoc_rules <- apriori(clean_data,parameter = list(supp = minsup,conf = minconf))

BIN
graphs.pdf Normal file

Binary file not shown.