Sei sulla pagina 1di 3

Assignment # 1 Sauban Ahmed

Business Stats ERP #: 13449


Spring 2020 MBA Evening

CODE:
Create 5 vectors ERP, name, sex, height, weight containing real data of your 04 classmates:

ERP <- c("18390","16798","18414","05227")


NAME <- c("Hassan Bin Sultan","S M Ovais","Maryam Siddiqi","Hamza Shafiq")
GENDER <- c("Male","Male","Female","Male")
HEIGHT <- c(178, 175, 165, 171)
WEIGHT <- c(78, 76, 70, 72)

Make sex as factor

Create a data frame student that contains 5 vectors created in part 1


STUDENT <- data.frame(ERP, NAME, GENDER, HEIGHT, WEIGHT)

Execute the head and tail commands and show the outputs
head(STUDENT)
tail(STUDENT)

Show the summary of all continuous columns


summary(HEIGHT)
summary(WEIGHT)
Assignment # 1 Sauban Ahmed
Business Stats ERP #: 13449
Spring 2020 MBA Evening

Create a frequency table of sex variable


table(STUDENT$GENDER)

Calculate mean, standard deviation, median, of all numeric columns


mean(STUDENT$HEIGHT)
sd (STUDENT$HEIGHT)
median(STUDENT$HEIGHT)

mean(STUDENT$WEIGHT)
sd (STUDENT$WEIGHT)
median(STUDENT$WEIGHT)

Draw scatterplot between height and weight column


plot(HEIGHT,WEIGHT)

This graph shows direct relationship between Height & Weight I,e, variables are somewhat
corelated. However, sample size is very small therefore the results need further evaluation before
using it make any decision.
Assignment # 1 Sauban Ahmed
Business Stats ERP #: 13449
Spring 2020 MBA Evening

Find the minimum and maximum height


min(HEIGHT)
max(HEIGHT)

Add two new in student data frame containing standardized version of height and weight
ST_HEIGHT <- ((STUDENT$HEIGHT-mean(STUDENT$HEIGHT))/sd (STUDENT$HEIGHT))
ST_WEIGHT <- ((STUDENT$WEIGHT-mean(STUDENT$WEIGHT))/sd (STUDENT$WEIGHT))
STUDENT <- data.frame(ERP, NAME, GENDER, HEIGHT, WEIGHT, ST_HEIGHT, ST_WEIGHT)
head(STUDENT)

DATA:
HEIGHT WEIGHT
ERP NAME GENDER
(cm) (Kg)
1839
Hassan Bin Sultan Male 178 78
0
1679
S M Ovais Male 175 76
8
1841
Maryam Siddiqi female 165 70
4
5227 Hamza Shafiq Male 171 72

Potrebbero piacerti anche