Loading Data into R
library(readr)
data <- read_csv("C:/Users/SoloTraveler/Downloads/data.csv")
## Parsed with column specification:
## cols(
## age = col_double(),
## stars = col_double(),
## race = col_character(),
## id = col_double(),
## restaurant = col_character(),
## sex = col_character()
## )
View(data)
Report
Find the total number of cases
length(data$id)
## [1] 1391
For each restaurant, find the total number of customers.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
dfr<-data%>%
count(restaurant)%>%
mutate(Percentage=prop.table(n)*100)
arrange(dfr,desc(n))
## # A tibble: 4 x 3
## restaurant n Percentage
## <chr> <int> <dbl>
## 1 Taco Bell 369 26.5
## 2 KFC 344 24.7
## 3 Burger King 340 24.4
## 4 McDonald 338 24.3
Analysis
1.The restaurants were displayed in the order they were because data frame is arranged in decreasing order of the total number of customers. 2.The percentage column was added to the table because of the mutate function which helps in identifying the restaurant with more customers.