0% found this document useful (0 votes)
50 views3 pages

Code:: Assignment # 1 Sauban Ahmed Business Stats ERP #: 13449 Spring 2020 MBA Evening

The document contains R code that analyzes data from a student data frame containing the ERP, name, gender, height, and weight of 4 classmates. The code creates the data frame, calculates summary statistics, adds standardized height and weight columns, and produces a scatter plot of height vs weight. The plot shows a direct relationship between height and weight but the sample size is too small to make decisions from.

Uploaded by

Sauban Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

Code:: Assignment # 1 Sauban Ahmed Business Stats ERP #: 13449 Spring 2020 MBA Evening

The document contains R code that analyzes data from a student data frame containing the ERP, name, gender, height, and weight of 4 classmates. The code creates the data frame, calculates summary statistics, adds standardized height and weight columns, and produces a scatter plot of height vs weight. The plot shows a direct relationship between height and weight but the sample size is too small to make decisions from.

Uploaded by

Sauban Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like