0
$\begingroup$
 company
 emp_NO sex department salary
 28    128   F         HR  17988
 8     108   M         SD  12984
 37    137   F         HR  23381
 36    136   F         HR  19101
 26    126   F         SD  15777
 33    133   F         HR  21082
 2     102   M         SD  15176
 31    131   F         HR  13723
 4     104   M         SD  17796
 10    110   M         SD  13238
 11    111   M         SD  17070
 43    143   F         AD  25728
 47    147   F         AD  30793
 39    139   F         AD  23063
 23    123   M         SD  13399
 1     101   M         SD  15721
 17    117   M         SD  15093 
 25    125   M         SD  15498
 3     103   M         SD  14353
 9     109   M         SD  15047 
 49    149   F         AD  25975
 12    112   M         SD  14516
 41    141   F         AD  26432
 5     105   M         SD  13813
 42    142   F         AD  23053
 44    144   F         AD  26081
 13    113   M         SD  15092
 29    129   F         HR   9511
 24    124   M         SD  14875
 7     107   M         SD  15365
 14    114   M         SD  14373
 46    146   F         AD  20145
 32    132   F         HR   6100
 34    134   F         HR    345
 27    127   F         HR  14187
 16    116   M         SD  13925
 30    130   F         HR  15228
 38    138   F         HR   3687
 18    118   M         SD  15173
 40    140   F         AD  27863
 48    148   F         AD  27953
 20    120   M         SD  16346
 45    145   F         AD  29704
 22    122   M         SD  16238
 19    119   M         SD  14912
 6     106   M         SD  14045
 15    115   M         SD  15068
 21    121   M         SD  14811
 50    150   F         AD  21992
 35    135   F         HR  33112

I generated this data set using an artificial data set.

I would like to compare employee’s salaries by gender using suitable summary statistics and graphs (or employee’s department).

$\endgroup$
2
  • 1
    $\begingroup$ What have you tried? Perhaps you're looking for a professional to analyse the data for you? $\endgroup$ Oct 21, 2014 at 9:26
  • 4
    $\begingroup$ Your question may have been migrated to this forum without your intervention, but for your future information just throwing a dataset at us and asking for an analysis is not an acceptable question. You're fortunate that people wanted to help. $\endgroup$
    – Nick Cox
    Oct 21, 2014 at 12:32

1 Answer 1

0
$\begingroup$
#initialize the counters of male and female employees
index_f=0
index_m=0
#initialize the vectors of salaries
salary_m=0
salary_f=0
for (i in 1:length(sex))
{
    if(sex[i]=="M")
    {
       index_m=index_m+1
       salary_m[index_m]=salary[i]
    }
    else
    {
       index_f=index_f+1
       salary_f[index_f]=salary[i]
    }
}
#do the t-test to compare means (parametric test)
t.test(salary_m,salary_f)
# do the wilcoxon test to compare means also (non-parametric test)
wilcox.test(salary_m,salary_f)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.