R Markdown

mba <- read.csv(paste("Deans Dilemma.csv", sep=""))
View(mba)

Attach the dataframe

attach(mba)

Summarize the data

summary(mba)
##       SlNo       Gender     Gender.B       Percent_SSC     Board_SSC  
##  Min.   :  1.0   F:127   Min.   :0.0000   Min.   :37.00   CBSE  :113  
##  1st Qu.: 98.5   M:264   1st Qu.:0.0000   1st Qu.:56.00   ICSE  : 77  
##  Median :196.0           Median :0.0000   Median :64.50   Others:201  
##  Mean   :196.0           Mean   :0.3248   Mean   :64.65               
##  3rd Qu.:293.5           3rd Qu.:1.0000   3rd Qu.:74.00               
##  Max.   :391.0           Max.   :1.0000   Max.   :87.20               
##                                                                       
##    Board_CBSE      Board_ICSE      Percent_HSC    Board_HSC  
##  Min.   :0.000   Min.   :0.0000   Min.   :40.0   CBSE  : 96  
##  1st Qu.:0.000   1st Qu.:0.0000   1st Qu.:54.0   ISC   : 48  
##  Median :0.000   Median :0.0000   Median :63.0   Others:247  
##  Mean   :0.289   Mean   :0.1969   Mean   :63.8               
##  3rd Qu.:1.000   3rd Qu.:0.0000   3rd Qu.:72.0               
##  Max.   :1.000   Max.   :1.0000   Max.   :94.7               
##                                                              
##     Stream_HSC  Percent_Degree                Course_Degree
##  Arts    : 18   Min.   :35.00   Arts                 : 13  
##  Commerce:222   1st Qu.:57.52   Commerce             :117  
##  Science :151   Median :63.00   Computer Applications: 32  
##                 Mean   :62.98   Engineering          : 37  
##                 3rd Qu.:69.00   Management           :163  
##                 Max.   :89.00   Others               :  5  
##                                 Science              : 24  
##   Degree_Engg      Experience_Yrs   Entrance_Test     S.TEST      
##  Min.   :0.00000   Min.   :0.0000   MAT    :265   Min.   :0.0000  
##  1st Qu.:0.00000   1st Qu.:0.0000   None   : 67   1st Qu.:1.0000  
##  Median :0.00000   Median :0.0000   K-MAT  : 24   Median :1.0000  
##  Mean   :0.09463   Mean   :0.4783   CAT    : 22   Mean   :0.8286  
##  3rd Qu.:0.00000   3rd Qu.:1.0000   PGCET  :  8   3rd Qu.:1.0000  
##  Max.   :1.00000   Max.   :3.0000   GCET   :  2   Max.   :1.0000  
##                                     (Other):  3                   
##  Percentile_ET    S.TEST.SCORE    Percent_MBA   
##  Min.   : 0.00   Min.   : 0.00   Min.   :50.83  
##  1st Qu.:41.19   1st Qu.:41.19   1st Qu.:57.20  
##  Median :62.00   Median :62.00   Median :61.01  
##  Mean   :54.93   Mean   :54.93   Mean   :61.67  
##  3rd Qu.:78.00   3rd Qu.:78.00   3rd Qu.:66.02  
##  Max.   :98.69   Max.   :98.69   Max.   :77.89  
##                                                 
##            Specialization_MBA Marks_Communication Marks_Projectwork
##  Marketing & Finance:222      Min.   :50.00       Min.   :50.00    
##  Marketing & HR     :156      1st Qu.:53.00       1st Qu.:64.00    
##  Marketing & IB     : 13      Median :58.00       Median :69.00    
##                               Mean   :60.54       Mean   :68.36    
##                               3rd Qu.:67.00       3rd Qu.:74.00    
##                               Max.   :88.00       Max.   :87.00    
##                                                                    
##    Marks_BOCA         Placement    Placement_B        Salary      
##  Min.   :50.00   Not Placed: 79   Min.   :0.000   Min.   :     0  
##  1st Qu.:57.00   Placed    :312   1st Qu.:1.000   1st Qu.:172800  
##  Median :63.00                    Median :1.000   Median :240000  
##  Mean   :64.38                    Mean   :0.798   Mean   :219078  
##  3rd Qu.:72.50                    3rd Qu.:1.000   3rd Qu.:300000  
##  Max.   :96.00                    Max.   :1.000   Max.   :940000  
## 
library(psych)
describe(mba)
##                     vars   n      mean        sd    median   trimmed
## SlNo                   1 391    196.00    113.02    196.00    196.00
## Gender*                2 391      1.68      0.47      2.00      1.72
## Gender.B               3 391      0.32      0.47      0.00      0.28
## Percent_SSC            4 391     64.65     10.96     64.50     64.76
## Board_SSC*             5 391      2.23      0.87      3.00      2.28
## Board_CBSE             6 391      0.29      0.45      0.00      0.24
## Board_ICSE             7 391      0.20      0.40      0.00      0.12
## Percent_HSC            8 391     63.80     11.42     63.00     63.34
## Board_HSC*             9 391      2.39      0.85      3.00      2.48
## Stream_HSC*           10 391      2.34      0.56      2.00      2.36
## Percent_Degree        11 391     62.98      8.92     63.00     62.91
## Course_Degree*        12 391      3.85      1.61      4.00      3.81
## Degree_Engg           13 391      0.09      0.29      0.00      0.00
## Experience_Yrs        14 391      0.48      0.67      0.00      0.36
## Entrance_Test*        15 391      5.85      1.35      6.00      6.08
## S.TEST                16 391      0.83      0.38      1.00      0.91
## Percentile_ET         17 391     54.93     31.17     62.00     56.87
## S.TEST.SCORE          18 391     54.93     31.17     62.00     56.87
## Percent_MBA           19 391     61.67      5.85     61.01     61.45
## Specialization_MBA*   20 391      1.47      0.56      1.00      1.42
## Marks_Communication   21 391     60.54      8.82     58.00     59.68
## Marks_Projectwork     22 391     68.36      7.15     69.00     68.60
## Marks_BOCA            23 391     64.38      9.58     63.00     64.08
## Placement*            24 391      1.80      0.40      2.00      1.87
## Placement_B           25 391      0.80      0.40      1.00      0.87
## Salary                26 391 219078.26 138311.65 240000.00 217011.50
##                          mad   min       max     range  skew kurtosis
## SlNo                  145.29  1.00    391.00    390.00  0.00    -1.21
## Gender*                 0.00  1.00      2.00      1.00 -0.75    -1.45
## Gender.B                0.00  0.00      1.00      1.00  0.75    -1.45
## Percent_SSC            12.60 37.00     87.20     50.20 -0.06    -0.72
## Board_SSC*              0.00  1.00      3.00      2.00 -0.45    -1.53
## Board_CBSE              0.00  0.00      1.00      1.00  0.93    -1.14
## Board_ICSE              0.00  0.00      1.00      1.00  1.52     0.31
## Percent_HSC            13.34 40.00     94.70     54.70  0.29    -0.67
## Board_HSC*              0.00  1.00      3.00      2.00 -0.83    -1.13
## Stream_HSC*             0.00  1.00      3.00      2.00 -0.12    -0.72
## Percent_Degree          8.90 35.00     89.00     54.00  0.05     0.24
## Course_Degree*          1.48  1.00      7.00      6.00  0.00    -1.08
## Degree_Engg             0.00  0.00      1.00      1.00  2.76     5.63
## Experience_Yrs          0.00  0.00      3.00      3.00  1.27     1.17
## Entrance_Test*          0.00  1.00      9.00      8.00 -2.52     7.04
## S.TEST                  0.00  0.00      1.00      1.00 -1.74     1.02
## Percentile_ET          25.20  0.00     98.69     98.69 -0.74    -0.69
## S.TEST.SCORE           25.20  0.00     98.69     98.69 -0.74    -0.69
## Percent_MBA             6.39 50.83     77.89     27.06  0.34    -0.52
## Specialization_MBA*     0.00  1.00      3.00      2.00  0.70    -0.56
## Marks_Communication     8.90 50.00     88.00     38.00  0.74    -0.25
## Marks_Projectwork       7.41 50.00     87.00     37.00 -0.26    -0.27
## Marks_BOCA             11.86 50.00     96.00     46.00  0.29    -0.85
## Placement*              0.00  1.00      2.00      1.00 -1.48     0.19
## Placement_B             0.00  0.00      1.00      1.00 -1.48     0.19
## Salary              88956.00  0.00 940000.00 940000.00  0.24     1.74
##                          se
## SlNo                   5.72
## Gender*                0.02
## Gender.B               0.02
## Percent_SSC            0.55
## Board_SSC*             0.04
## Board_CBSE             0.02
## Board_ICSE             0.02
## Percent_HSC            0.58
## Board_HSC*             0.04
## Stream_HSC*            0.03
## Percent_Degree         0.45
## Course_Degree*         0.08
## Degree_Engg            0.01
## Experience_Yrs         0.03
## Entrance_Test*         0.07
## S.TEST                 0.02
## Percentile_ET          1.58
## S.TEST.SCORE           1.58
## Percent_MBA            0.30
## Specialization_MBA*    0.03
## Marks_Communication    0.45
## Marks_Projectwork      0.36
## Marks_BOCA             0.48
## Placement*             0.02
## Placement_B            0.02
## Salary              6994.72

Q1. What is the median salary of all the students?

median(mba$Salary)
## [1] 240000

Q2. What percentage of students were placed? Answer rounding off to 2 decimal places.

summary(mba$Placement)
## Not Placed     Placed 
##         79        312
100*mean(mba$Placement_B)
## [1] 79.7954

Q3. Create a dataframe called “placed” having the subset of students who were placed

placed <- mba[ which(mba$Placement=='Placed') , ] 

Q4. What is the median salary of students who were placed, excluding those who were not placed?

Method 1:

median (mba$Salary[mba$Salary > 0] )
## [1] 260000

Method 2:

median(placed$Salary)
## [1] 260000

Q5. Considering placed students, create a table giving the mean salary of males and females?

Method 1: Using aggregate()

aggregate(placed$Salary, by=list(Sex = placed$Gender), mean)
##   Sex        x
## 1   F 253068.0
## 2   M 284241.9

Method 2: Using by()

by(placed$Salary, placed$Gender, mean)
## placed$Gender: F
## [1] 253068
## -------------------------------------------------------- 
## placed$Gender: M
## [1] 284241.9

Q7. Create a dataframe called notplaced, containing only those students

who were not placed.

notplaced <- mba[ which(mba$Placement=='Not Placed') , ] 

Q10. Create a dataframe called placedET, representing students who were placed

after the MBA and who also gave some MBA entrance test

before admission into the MBA program.

Method 1:

placedET <- placed[ which(placed$S.TEST==1) , ] 

Method 2:

placedET <- placed[ which(placed$Entrance_Test != "None") , ] 
View(placedET)

Including Plots

You can also embed plots, for example: ###Q11.generate the following histogram showing a breakup of the MBA performance of the students who were placed

hist(placed$Percent_MBA , main = "MBA Performance of placed students" , xlab = "MBA Percentage" , ylab = "Count" , xlim = c(50,80) , ylim = c(0,150) , col = "grey" , breaks = c(50,seq(60,80,10)))

###Q12.Dataframe called notplaced, that contains a subset of only those students who were NOT placed after their MBA.

notplaced <- subset(mba , Placement == "Not Placed" , select = c(Percent_MBA , Gender , Salary))
notplaced
##     Percent_MBA Gender Salary
## 11        69.78      F      0
## 16        53.29      F      0
## 20        54.65      M      0
## 40        67.28      F      0
## 42        51.75      F      0
## 43        56.34      M      0
## 59        51.29      M      0
## 64        52.56      M      0
## 68        51.45      M      0
## 75        51.21      M      0
## 79        71.63      F      0
## 82        56.11      F      0
## 88        56.19      M      0
## 89        65.49      F      0
## 94        61.31      M      0
## 98        60.29      M      0
## 100       56.45      F      0
## 109       72.00      M      0
## 112       54.76      F      0
## 128       71.15      F      0
## 144       67.13      F      0
## 149       55.83      M      0
## 162       58.00      M      0
## 166       55.41      M      0
## 175       59.47      M      0
## 176       64.95      F      0
## 184       55.30      M      0
## 191       56.09      M      0
## 194       60.64      M      0
## 204       58.81      M      0
## 220       64.15      M      0
## 226       62.29      F      0
## 231       62.83      F      0
## 236       57.32      F      0
## 240       61.90      M      0
## 241       61.22      M      0
## 248       58.52      M      0
## 252       52.32      M      0
## 258       55.87      M      0
## 266       65.99      M      0
## 269       61.87      M      0
## 272       65.13      M      0
## 284       74.56      F      0
## 285       54.99      M      0
## 287       75.71      M      0
## 288       57.16      M      0
## 289       58.79      F      0
## 290       65.48      M      0
## 291       69.28      F      0
## 298       67.44      F      0
## 301       60.69      M      0
## 307       72.14      F      0
## 310       60.02      M      0
## 315       63.83      F      0
## 317       59.81      M      0
## 318       61.66      F      0
## 322       57.29      F      0
## 324       62.93      F      0
## 326       56.13      M      0
## 328       66.94      F      0
## 329       63.94      M      0
## 330       62.50      F      0
## 332       66.18      M      0
## 336       64.74      M      0
## 338       65.28      M      0
## 344       63.53      F      0
## 350       58.44      M      0
## 352       72.21      F      0
## 355       51.48      M      0
## 364       53.39      M      0
## 375       62.42      F      0
## 376       60.22      M      0
## 377       52.36      M      0
## 379       56.00      M      0
## 382       50.83      M      0
## 383       56.81      F      0
## 384       59.14      M      0
## 386       67.94      M      0
## 391       60.36      M      0

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot. ###Q13. Draw two histograms side-by-side, visually comparing the MBA performance of Placed and Not Placed students.

par(mfrow = c(1,2))
hist(placedET$Percent_MBA , main = "MBA Performance of placed students" , xlab = "MBA Percentage" , ylab = "Count" , xlim = c(50,80) , ylim = c(0,150) , col = "grey" , breaks = c(50,seq(60,80,10)))

hist(notplaced$Percent_MBA , main = "MBA Performance of not placed students" , xlab = "MBA Percentage" , ylab = "Count" , xlim = c(50,80) , ylim = c(0,40) , col = "grey" , breaks = c(50,seq(60,80,10)))

###Q14.Draw two boxplots, one below the other, comparing the distribution of salaries of males and females who were placed.

par(mfrow = c(1,1))
library(lattice)
bwplot(Gender ~ Salary , data = placedET, horizontal = TRUE , xlab = "Salary" , ylab = "Gender" , main = "Comparison of Salaries of Males and Females")

###Q15 Create a dataframe called placedET, representing students who were placed after the MBA and who also gave some MBA entrance test before admission into the MBA program

placedET <- subset(mba , Placement == "Placed" & S.TEST == 1 , select = c(Salary , Percent_MBA , Percentile_ET))
placedET
##     Salary Percent_MBA Percentile_ET
## 1   270000       58.80         55.00
## 2   200000       66.28         86.50
## 4   250000       57.80         75.00
## 5   180000       59.43         66.00
## 8   235000       57.23         43.12
## 9   425000       55.50         96.80
## 12  250000       54.01         79.00
## 13  180000       51.58         55.00
## 15  450000       58.21         33.00
## 19  252000       62.14         67.00
## 21  280000       63.26         70.00
## 22  231000       61.29         91.34
## 23  224000       62.51         35.00
## 24  120000       52.21         54.00
## 25  260000       60.85         62.00
## 26  300000       60.77         75.00
## 28  120000       58.56         49.00
## 29  250000       63.70         60.00
## 30  180000       65.04         62.00
## 31  218000       68.63         68.00
## 33  150000       54.96         76.00
## 34  250000       64.19         48.00
## 35  200000       64.66         72.00
## 36  300000       62.54         60.00
## 37  330000       52.41         79.00
## 38  265000       56.61          0.00
## 39  340000       61.83         70.00
## 41  177600       64.08         68.00
## 44  236000       77.89         50.48
## 45  265000       56.70         50.00
## 47  393000       69.06         95.00
## 48  360000       68.81         55.53
## 49  300000       63.62         92.00
## 51  360000       74.01         97.40
## 52  180000       65.33         76.00
## 53  180000       62.80         74.00
## 55  240000       57.55         94.00
## 56  300000       60.76         41.38
## 57  265000       57.69         68.00
## 58  350000       64.15         73.35
## 60  250000       56.70         52.00
## 61  180000       58.32         64.00
## 62  278000       62.21         50.89
## 63  150000       57.61         83.00
## 65  260000       72.78         88.00
## 66  180000       62.77         68.44
## 67  300000       62.74         71.00
## 69  400000       68.85          0.00
## 70  320000       55.47         58.00
## 71  240000       56.86         53.70
## 72  411000       62.56         93.00
## 73  287000       66.72         60.00
## 74  198000       69.76         65.00
## 76  300000       62.90         95.00
## 77  200000       69.70         89.00
## 78  180000       66.53         58.00
## 80  204000       54.55         78.00
## 81  250000       62.46         64.00
## 83  200000       62.98         65.00
## 84  275000       62.27         97.33
## 85  192000       62.65         67.00
## 87  300000       60.91         53.00
## 90  450000       71.04         87.00
## 91  216000       65.56         78.00
## 92  220000       52.71         71.00
## 95  300000       67.31         68.00
## 96  240000       66.88         68.00
## 97  360000       63.59         80.00
## 99  268000       57.99         74.00
## 101 265000       56.66         57.60
## 102 260000       57.24         60.00
## 104 300000       62.48         61.60
## 105 240000       59.69         59.00
## 107 240000       64.75         44.56
## 108 400000       57.76         13.00
## 111 250000       76.72         78.00
## 114 180000       59.50         68.50
## 116 240000       58.78         61.00
## 117 120000       57.10         89.69
## 119 275000       58.46         68.92
## 120 275000       60.99         68.71
## 121 150000       59.24         79.00
## 122 275000       68.07         70.00
## 124 240000       58.75         41.00
## 126 360000       65.45         89.00
## 127 280000       62.40         46.92
## 129 325000       60.43         50.00
## 130 204000       60.76         40.00
## 131 240000       66.94         95.00
## 132 240000       68.53         95.50
## 133 336000       61.41         96.00
## 134 218000       59.75         86.00
## 136 336000       67.20         84.27
## 137 190000       67.00         74.00
## 138 230000       64.27         61.00
## 139 390000       51.24         94.30
## 140 500000       57.65         69.00
## 141 270000       59.42         86.04
## 142 150000       67.99         75.00
## 143 240000       62.35         67.00
## 145 276000       62.01         40.00
## 146 300000       70.20         86.00
## 147 168000       60.44         82.00
## 148 300000       66.69         84.00
## 150 270000       59.81          0.00
## 152 300000       62.00         55.00
## 153 400000       76.18         78.74
## 154 220000       57.03         67.00
## 155 180000       59.08         75.00
## 156 180000       58.85         64.00
## 157 210000       64.36         58.00
## 158 210000       62.36         62.00
## 159 300000       68.03         92.00
## 160 290000       66.86         92.00
## 161 180000       62.79         67.00
## 163 230000       59.47         72.00
## 164 282000       64.63         47.41
## 165 260000       53.57         29.00
## 167 180000       66.50         56.39
## 168 260000       54.97         53.88
## 169 400000       56.51         79.00
## 170 420000       62.16         95.46
## 172 300000       64.44         66.00
## 173 150000       69.03         93.91
## 174 220000       57.31         70.00
## 177 380000       60.44         78.00
## 179 300000       61.31         57.50
## 180 252000       55.42         67.00
## 181 280000       63.39         58.00
## 182 240000       65.83         85.00
## 183 360000       58.23         55.00
## 185 180000       65.69         71.00
## 186 450000       67.83         95.00
## 187 200000       73.52         80.00
## 188 300000       58.31         84.00
## 193 250000       54.80         57.20
## 195 250000       53.94         58.00
## 196 280000       63.08         72.15
## 197 250000       55.01         53.70
## 198 216000       60.50         89.00
## 199 204000       52.42         39.00
## 200 300000       70.85         96.00
## 201 240000       67.05         80.00
## 202 276000       70.48         97.00
## 203 940000       64.34         82.66
## 205 250000       71.49         55.67
## 206 300000       59.99         85.00
## 207 180000       57.98         14.99
## 208 236000       71.00         80.40
## 209 240000       56.70         60.00
## 210 250000       61.26         64.00
## 211 350000       73.33         75.00
## 213 210000       68.20         70.00
## 214 250000       58.40         55.50
## 215 400000       76.26         81.20
## 216 300000       70.71         84.00
## 217 480000       61.79         86.00
## 218 250000       68.55         90.00
## 219 320000       67.54         89.95
## 221 385000       69.94         65.00
## 222 360000       60.78         80.00
## 223 300000       53.49         74.40
## 225 250000       60.98         65.00
## 227 250000       67.13         94.00
## 228 275000       58.73         43.00
## 229 200000       65.63         55.60
## 230 150000       61.58         78.00
## 232 300000       60.95         65.00
## 233 225000       60.41         56.00
## 235 250000       71.77         96.00
## 237 220000       54.43         58.00
## 239 265000       56.94         56.00
## 242 260000       61.29         60.00
## 243 300000       60.39         89.00
## 244 180000       51.73         39.00
## 245 530000       59.54         65.00
## 246 156000       56.75         66.60
## 247 263000       58.95         40.00
## 249 400000       63.23         72.00
## 250 233000       55.14         85.00
## 251 300000       62.28         83.00
## 253 240000       64.08         57.00
## 254 180000       58.54         64.25
## 256 198000       55.67         40.00
## 259 690000       61.30         56.00
## 260 270000       58.87         83.00
## 261 240000       65.25         98.00
## 263 340000       62.48         86.00
## 264 250000       53.20         70.00
## 267 255000       52.72         80.00
## 268 300000       55.03         93.40
## 270 150000       60.59         62.00
## 271 300000       72.29         75.00
## 273 270000       59.71         49.70
## 275 180000       62.72         57.63
## 276 285000       66.06         75.20
## 278 500000       66.46         75.00
## 279 250000       65.52         53.04
## 283 240000       70.10         88.00
## 286 240000       52.38         63.00
## 292 476000       66.39         80.00
## 293 290000       66.04         63.79
## 294 690000       72.97         95.50
## 295 300000       52.64         84.00
## 296 250000       64.79         49.00
## 297 162000       59.32         67.00
## 300 500000       66.23         64.00
## 302 220000       57.90         55.00
## 303 270000       58.67         76.20
## 304 650000       70.81         89.00
## 305 350000       68.07         73.00
## 306 300000       62.00         44.20
## 308 265000       56.60         57.00
## 309 180000       54.04         35.00
## 311 300000       64.28         62.00
## 313 300000       68.68         74.00
## 316 240000       54.12          0.00
## 319 276000       61.82         60.00
## 323 252000       71.43         82.00
## 325 280000       64.86         95.00
## 327 350000       66.63         60.00
## 333 264000       61.01         72.00
## 334 270000       57.34         93.40
## 335 300000       56.63         80.00
## 337 275000       58.95         84.00
## 339 300000       54.50         85.00
## 340 250000       54.48         78.00
## 341 260000       69.71         59.32
## 342 185000       71.96         88.00
## 343 216000       63.91         79.00
## 345 265000       55.80         73.00
## 346 300000       52.81         87.55
## 347 325000       56.12         84.00
## 348 267000       53.37         83.00
## 351 240000       60.11         61.28
## 353 260000       58.30         66.00
## 354 240000       69.12         63.00
## 356 250000       56.98         63.00
## 357 180000       63.42         60.00
## 359 210000       67.69         80.00
## 360 250000       52.64         48.00
## 361 250000       56.81         62.00
## 362 426000       60.39         26.53
## 363 270000       60.04         98.00
## 365 300000       71.55         88.56
## 366 132000       56.45         64.00
## 367 144000       62.92         92.66
## 369 216000       56.49         67.00
## 370 400000       74.49         91.00
## 371 275000       53.62         74.00
## 372 295000       69.72         59.00
## 373 360000       65.80         73.00
## 374 204000       60.23         70.00
## 378 350000       66.22         66.00
## 380 300000       77.30         96.16
## 381 180000       53.19          0.00
## 385 252000       61.00          0.00
## 387 162000       58.63         34.53
## 388 450000       59.50         50.53
## 389 240000       61.63         60.00
## 390 300000       70.17         77.00

Q16 Draw a Scatter Plot Matrix for 3 variables – {Salary, Percent_MBA, Percentile_ET} using the dataframe placedET.

library(car)
library(psych)
scatterplotMatrix(formula = ~ Salary + Percent_MBA + Percentile_ET, data = placedET)