setwd("C:/Users/Hervi/Data")
pi_zzadelivery=read.csv("C:/Users/Hervi/Data/pizza_delivery.csv",header=TRUE,sep=",")
pi_zzadelivery
attach(pi_zzadelivery)

Histogram of the Temperature oF the Pizza

hist(pi_zzadelivery$temperature,
  main = 'Histogram of Temperature',
  xlab ='Temperature (°C)', 
  ylab ='Deliveries',
  col='violet',
  ylim = c(0,90),
  xlim = c(45,80),
  breaks=50)

lines(c(65,65),
      c(0,300),col= "blue",
      type='l'
      ,lty=2,lwd=3)

Deliveries By Branch

branch = (pi_zzadelivery$branch)
transform(table(branch))
transform(table(branch)/length (branch))
plot.ecdf(pi_zzadelivery$time,
          main= "Pizza Delivery Time",
          xlab ="Time",
          col= "violet")

Histogram for Delivery Time

hist(pi_zzadelivery$time, 
     main="Pizza Delivery Time",
     xlab="Time",
     col="pink")

***using absolute and relative frequency***

ABSOLUTE FREQUENCY

hist(pi_zzadelivery$time, 
     main="Absolute Frequency",
     xlab="Time",
     col="red")

RELATIVE FREQUENCY

hist(pi_zzadelivery$time, freq = F,
     breaks = 20,
     main="Relative Frequency",
     xlab="Time",
     col="orange")

library(MASS)
truehist(pi_zzadelivery$time, 
         main="Pizza Delivery Time",
         xlab = "Time",
         ylab= "Relative Frequency", 
         col="green" )

***Create a contingency table for the two new variables***
pi_zzadelivery=read.csv("C:/Users/Hervi/Data/pizza_delivery.csv")
pi_zzadelivery$tempcat<- cut(pi_zzadelivery$temperature, 
                             breaks= c(0,65,100))
pi_zzadelivery$timecat<- cut(pi_zzadelivery$time, 
                             breaks= c(0,30,100))
attach(pi_zzadelivery)
## The following object is masked _by_ .GlobalEnv:
## 
##     branch
## The following objects are masked from pi_zzadelivery (pos = 4):
## 
##     bill, branch, date, discount_customer, driver, free_wine, got_wine,
##     ï..day, operator, pizzas, temperature, time
addmargins(table(tempcat,timecat))
##           timecat
## tempcat    (0,30] (30,100]  Sum
##   (0,65]      101      691  792
##   (65,100]    213      261  474
##   Sum         314      952 1266

ODDSRATIO

oddsratio <- (101*261)/(213*691)
oddsratio
## [1] 0.1791036