You are on page 1of 3

#1

# Create the data vector


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

# Compute for the mean


mean(applications)

# Compute for the median


median(applications)

# Install the modeest package


install.packages("modeest")

# Load modeest package


library(modeest)

# Compute for the mode


mfv(applications)

# Create vector of maximum and minimum values


x <-c(max(applications), min(applications))

# Compute for the Midrange


midrange <- mean(x)
midrange

#2

# Create the data vectors


finalgrades <- c(89, 84, 89, 91, 88, 95, 87, 89, 87)
units <- c(3, 3, 3, 2, 3, 3, 3, 3, 6)

# Compute for the weighted mean


weighted.mean(finalgrades, units)

# YES

#3

# Create the data vector


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

# Compute for the mean


mean(unitsproduced)

# Compute for the median


median(unitsproduced)

# Compute for the mode


mfv(unitsproduced)

# Create vector of maximum and minimum values


y <-c(max(unitsproduced), min(unitsproduced))

# Compute for the midrange


midrange <- mean(y)
midrange

#4

# Create the data vector


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

# Compute for the mean


mean(minutes)

# Compute for the meadian


median(minutes)

# Compute for the mode


mfv(minutes)

# Create vector of maximum and minimum values


z <-c(max(minutes), min(minutes))

# Compute for the midrange


midrange <- mean(z)
midrange

#5
#Load packages
library(modeest)

# Import "salaries.csv" and assign it to "salaries"


salaries <-read.csv("salaries.csv")
head(salaries)

# Mode for all the variables


yrs.since.phd <- c(salaries$yrs.since.phd)
mfv(yrs.since.phd)

yrs.service <- c(salaries$yrs.service)


mfv(yrs.service)

salary <- c(salaries$salary)


mfv(salary)

rank <- c(salaries$rank)


mfv(rank)

discipline <- c(salaries$discipline)


mfv(discipline)

sex <- c(salaries$sex)


mfv(sex)

# Load packages
library(readr)
library(pander)

# Average salary of male and female


output1 <-aggregate(salary ~sex, salaries, mean)
pander(output1)

# Average years of service according to rank


output2 <-tapply(salaries$yrs.service, salaries$rank,mean)
pander(output2)

You might also like