Instructions:
Analysis (Opinion) 1. The restaurants are displayed in the order they are because data frame is ordered by the frequency. 2. The addition of the percentage column to the table allows the reader to see percentage of customers for each restaurant vs overall restaurant. ————————————————————————
Test out all the libraries we need for the course.
library(readr)
data <- read_csv("/Users/mex/2023 Session/data.2.csv")
length(data$id)
## [1] 1282
library(dplyr)
data %>%
group_by(restaurant) %>%
summarise(count = n()) %>%
mutate(Percentage = count/sum(count) * 100) %>%
arrange(desc(count))
## # A tibble: 4 × 3
## restaurant count Percentage
## <chr> <int> <dbl>
## 1 KFC 335 26.1
## 2 McDonald 320 25.0
## 3 Burger King 319 24.9
## 4 Taco Bell 308 24.0
mydata1 <- matrix(c(3.0585,3.017, 3.100,3.0505, 2.982, 3.119,2.9640, 2.979, 2.949,2.8670, 2.913, 2.821),ncol=3,byrow=TRUE)
colnames(mydata1) <- c("Overall","Male","Female")
rownames(mydata1) <- c("McDonald","KFC","Taco Bell","Burger King")
mydata1 <- as.table(mydata1)
mydata1
## Overall Male Female
## McDonald 3.0585 3.0170 3.1000
## KFC 3.0505 2.9820 3.1190
## Taco Bell 2.9640 2.9790 2.9490
## Burger King 2.8670 2.9130 2.8210