# Compare continuous variable between groups

 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
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
12    112   M         SD  14516
5     105   M         SD  13813
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
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
20    120   M         SD  16346
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
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).

• What have you tried? Perhaps you're looking for a professional to analyse the data for you? Oct 21, 2014 at 9:26
• 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. Oct 21, 2014 at 12:32

#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)