#Assignment 2

exam_score = data.frame(
  ID = c(1, 2, 3, 4, 5),
  Name = c("Alice", "Bob", "David", "John", "Jenny"),
  Age = c(20, 25, 30, 22, 18),
  Score = c(100, 78, 90, 55, 81)
)
exam_score
##   ID  Name Age Score
## 1  1 Alice  20   100
## 2  2   Bob  25    78
## 3  3 David  30    90
## 4  4  John  22    55
## 5  5 Jenny  18    81

Adding two new row

Row1 = data.frame(ID=6,Name ="marley",Age = 20,Score = 65)
Row2 = data.frame(ID=7,Name ="Austin",Age = 21,Score = 77)
exam_score = rbind(exam_score,Row1,Row2)
exam_score
##   ID   Name Age Score
## 1  1  Alice  20   100
## 2  2    Bob  25    78
## 3  3  David  30    90
## 4  4   John  22    55
## 5  5  Jenny  18    81
## 6  6 marley  20    65
## 7  7 Austin  21    77

Adding new column

Income = c(1500,1235,1250,1600,2000,1800,1400)
exam_score = cbind(exam_score,Income)
exam_score
##   ID   Name Age Score Income
## 1  1  Alice  20   100   1500
## 2  2    Bob  25    78   1235
## 3  3  David  30    90   1250
## 4  4   John  22    55   1600
## 5  5  Jenny  18    81   2000
## 6  6 marley  20    65   1800
## 7  7 Austin  21    77   1400

#Find max, min, median, sum, mean, standard deviation, variance, and quantiles of columns Age, Score, and Income. #Finding max, min, median, sum, mean, standard deviation, variance, and quantiles of columns Age.

Maximum = max(exam_score$Age)
Maximum
## [1] 30
Minimum = min(exam_score$Age)
Minimum
## [1] 18
Median = median(exam_score$Age)
Median
## [1] 21
Summation = sum(exam_score$Age)
Summation
## [1] 156
Standard_daviation = sd(exam_score$Age)
Standard_daviation
## [1] 4.029652
Variance = var(exam_score$Age)
Variance
## [1] 16.2381
Quantile = quantile(exam_score$Age)
Quantile
##   0%  25%  50%  75% 100% 
## 18.0 20.0 21.0 23.5 30.0

#Finding max, min, median, sum, mean, standard deviation, variance, and quantiles of columns score.

Maximum = max(exam_score$Score)
Maximum
## [1] 100
Minimum = min(exam_score$Score)
Minimum
## [1] 55
Median = median(exam_score$Score)
Median
## [1] 78
Summation = sum(exam_score$Score)
Summation
## [1] 546
Standard_daviation = sd(exam_score$Score)
Standard_daviation
## [1] 14.92202
Variance = var(exam_score$Score)
Variance
## [1] 222.6667
Quantile = quantile(exam_score$Score)
Quantile
##    0%   25%   50%   75%  100% 
##  55.0  71.0  78.0  85.5 100.0

#Finding max, min, median, sum, mean, standard deviation, variance, and quantiles of columns Income.

Maximum = max(exam_score$Income)
Maximum
## [1] 2000
Minimum = min(exam_score$Income)
Minimum
## [1] 1235
Median = median(exam_score$Income)
Median
## [1] 1500
Summation = sum(exam_score$Income)
Summation
## [1] 10785
Standard_daviation = sd(exam_score$Income)
Standard_daviation
## [1] 283.1729
Variance = var(exam_score$Income)
Variance
## [1] 80186.9
Quantile = quantile(exam_score$Income)
Quantile
##   0%  25%  50%  75% 100% 
## 1235 1325 1500 1700 2000

b.Find correlation

##Age and score

cor(exam_score$Age,exam_score$Score)
## [1] 0.1857071

##Age and income

cor(exam_score$Age,exam_score$Income)
## [1] -0.7852779

##Score and income

cor(exam_score$Score,exam_score$Income)
## [1] -0.2997664
exam_score
##   ID   Name Age Score Income
## 1  1  Alice  20   100   1500
## 2  2    Bob  25    78   1235
## 3  3  David  30    90   1250
## 4  4   John  22    55   1600
## 5  5  Jenny  18    81   2000
## 6  6 marley  20    65   1800
## 7  7 Austin  21    77   1400

#Select rows where the score is greater than or equal to 80

exam_score[exam_score$Score>=80, ]
##   ID  Name Age Score Income
## 1  1 Alice  20   100   1500
## 3  3 David  30    90   1250
## 5  5 Jenny  18    81   2000

#Select rows with the age range of 20 to 30

exam_score[exam_score$Age>=20 & exam_score$Age<=30 , ]
##   ID   Name Age Score Income
## 1  1  Alice  20   100   1500
## 2  2    Bob  25    78   1235
## 3  3  David  30    90   1250
## 4  4   John  22    55   1600
## 6  6 marley  20    65   1800
## 7  7 Austin  21    77   1400