library(modeest)
library(pander)

Practice Exercise 6-1

Find the mean, median, mode and midrange of the following data set on the total weight, in kilograms, of ready-to-cook chicken inasal leg quarters sold by a frozen foods retail store during selected days of June and July. Express your answers up to 2 decimal places.

\(~\) Data: 35.2, 7.0, 24.0, 42.4, 33.0, 27.5, 24.0, 21.0, 8.0, 45.6, 25.9, 14.8, 29.8, 21.0, 17.5, 9.7, 40.0, 18.8, 57.9, 21.0, 12.0, 12.0, 19.6, 51.5, 12.0, 36.8, 13.7, 32.8, 12.0, 10.5, 22.5, 19.5, 37.5, 35.0, 10.5, 33.6, 14.5, 36.5, 17.9, 26.9, 12.0, 41.5.

weight <- c(35.2, 7.0, 24.0, 42.4, 33.0, 27.5, 24.0, 21.0, 8.0, 45.6, 25.9, 14.8, 29.8, 21.0, 17.5, 9.7, 40.0, 18.8, 57.9, 21.0, 12.0, 12.0, 19.6, 51.5, 12.0, 36.8, 13.7, 32.8, 12.0, 10.5, 22.5, 19.5, 37.5, 35.0, 10.5, 33.6, 14.5, 36.5, 17.9, 26.9, 12.0, 41.5)

\(~\)

For the mean:

x1 <- mean(weight)
pander(round(x1, digits = 2))

24.88

\(~\)

For the median:

x2 <- median(weight)
pander(round(x2, digits = 2))

21.75

\(~\)

For the mode:

pander(mfv(weight))

12

\(~\)

For the midrange:

x3 <- mean(c(max(weight), min(weight)))
pander(round(x3, digits = 2))

32.45

\(~\)

Problem 1:

Find the mean, median, mode, and midrange for the following data set representing the number of applications for a fiber internet plan received in a day by a service provider, over the past 30 working days. (10 points)

Data: 45, 46, 48, 53, 54, 55, 56, 59, 62, 63, 65, 66, 66, 69, 69, 70, 71, 71, 73, 73, 74, 75, 75, 75, 77, 78, 81, 82, 82, 83.

applic <- c(45, 46, 48, 53, 54, 55, 56, 59, 62, 63, 65, 66, 66, 69, 69, 70, 71, 71, 73, 73, 74, 75, 75, 75, 77, 78, 81, 82, 82, 83)

\(~\)

For the mean:

x1 <- mean(applic)
pander(round(x1, digits = 2))

67.2

\(~\)

For the median:

x2 <- median(applic)
pander(round(x2, digits = 2))

69.5

\(~\)

For the mode:

pander(mfv(applic))

75

\(~\)

For the midrange:

x3 <- mean(c(max(applic), min(applic)))
pander(round(x3, digits = 2))

64

\(~\)

Problem 2:

A BS Accountancy student received the following final grades in his course during the second semester of his sophomore year. Find his general weighted average if his final grades were as follows. Would he be part of the Dean’s List for the semester if the cutoff grade is 88? (5 points)

COURSE NO. DESCRIPTIVE TITLE UNITS FINAL GRADE
CFE 104 CICM Missionary Identity 3 89
GSTS Science, Technology, and Society 3 84
GMATH Mathematics in the Modern World 3 89
FIT AQ Physical Activity Towards Health & Fitness 2 91
AE221 Intermediate Accounting 3 3 88
AE222 Accounting Information Systems 3 95
BLR221 Business Laws and Regulations 2 3 87
CMPC221 Accounting for Business Combinations 3 89
INCTAXa Income Taxation 6 87

For the general weighted average:

units <- c(3, 3, 3, 2, 3, 3, 3, 3, 6)
grades <- c(89, 84, 89, 91, 88, 95, 87, 89, 87)
x1 <- weighted.mean(grades, units)
pander(round(x1, digits = 2))

88.52

The general weighted average of the student is 88.52. With a cutoff grade of 88 for Dean’s listers, this student would then be a part of the Dean’s List.

\(~\)

Problem 3:

Below is the number of units produced by a factory in the last 33 days of production. Assuming the data to be a sample, compute the mean, median, mode and midrange. (10 points)

Data: 322, 343, 348, 358, 361, 366, 374, 376, 386, 390, 396, 329, 344, 349, 359, 362, 366, 375, 377, 389, 392, 397, 333, 347, 351, 360, 365, 367, 376, 379, 390, 395, 398.

units <- c(322, 343, 348, 358, 361, 366, 374, 376, 386, 390, 396, 329, 344, 349, 359, 362, 366, 375, 377, 389, 392, 397,  333, 347, 351, 360, 365, 367, 376, 379, 390,  395, 398)

\(~\)

For the mean:

x1 <- mean(units)
pander(round(x1, digits = 2))

367.3

\(~\)

For the median:

x2 <- median(units)
pander(round(x2, digits = 2))

366

\(~\)

For the mode:

pander(mfv(units))

366, 376 and 390

The data set is multimodal where the mode values are 366, 376, and 390.

\(~\)

For the midrange:

x3 <- mean(c(max(units),min(units)))
pander(round(x3, digits = 2))

360

\(~\)

Problem 4:

The table that follows shows the time (in minutes) it takes for customers to wait in line before being served at a fast food restaurant. Assuming the data to be a sample, compute the mean, median, mode and midrange. (10 points)

Data: 3.2, 3.3, 3.5, 3.9, 4.1, 4.4, 4.7, 4.8, 5.2, 5.6, 5.6, 5.7, 5.8, 6.0, 6.2, 6.3, 6.4, 6.5, 6.7, 6.7, 6.9, 7.0, 7.2, 7.5, 8.0, 8.8, 8.9, 9.4, 9.7, 9.9, 10.0, 11.3, 12.4, 12.5, 14.8, 15.0, 16.5, 16.8, 17.2, 19.3.

wait <- c(3.2, 3.3, 3.5, 3.9, 4.1, 4.4, 4.7, 4.8, 5.2, 5.6, 5.6, 5.7, 5.8, 6.0, 6.2, 6.3, 6.4, 6.5, 6.7, 6.7, 6.9, 7.0, 7.2, 7.5,   8.0, 8.8,   8.9, 9.4,   9.7, 9.9, 10.0, 11.3, 12.4, 12.5,   14.8,   15.0,   16.5,   16.8, 17.2, 19.3)

\(~\)

For the mean:

x1 <- mean(wait)
pander(round(x1, digits = 2))

8.34

\(~\)

For the median:

x2 <- median(wait)
pander(round(x2, digits = 2))

6.8

\(~\)

For the mode:

pander(mfv(wait))

5.6 and 6.7

The data set is bimodal with the mode values equal to 5.6 and 6.7.

\(~\)

For the midrange:

x3 <- mean(c(max(wait), min(wait)))
pander(round(x3, digits = 2))

11.25

\(~\)

Problem 5:

Using RStudio and the “salaries.csv” data file, determine

  1. the mode for all the variables.
data <- read.csv("salaries.csv")
head(data)
pander(as.character(mfv(data$rank)))

Prof

pander(as.character(mfv(data$discipline)))

B

pander(mfv(data$yrs.since.phd))

4

pander(mfv(data$yrs.service))

3

pander(as.character(mfv(data$sex)))

Male

pander(mfv(data$salary))

92000

\(~\)

  1. the average salary of male and female teachers
x1 <- tapply(data$salary, data$sex, mean)
pander(round(x1, digits = 2))
Female Male
101002 115090

\(~\)

  1. the average years of service of the teachers grouped according to rank.
x2 <- tapply(data$yrs.service, data$rank, mean)
pander(round(x2, digits = 2))
AssocProf AsstProf Prof
11.95 2.37 22.82