` 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).

**Contents**hide

#### Best Answer

You should read some introductory statistics material. For **R** in particular, there are some introduction to R guides at the R website (under documentation > manuals). Also an internet search of *"Introductory statistics using R"* will lead to many guides / blogs that answer and explain such analysis using R.

So below is not an attempt at a full answer but shows a couple of functions you may find useful.

`# Quick look at data # boxplot boxplot(company$salary ~ company$sex) `

See `?boxplot`

also http://www.statmethods.net/graphs/boxplot.html

`# histogram par(mfrow=c(1,2)) hist(company$salary[company$sex=="M"]) hist(company$salary[company$sex=="F"]) `

See `?hist`

and also http://www.statmethods.net/graphs/density.html

`# summary tapply(company$salary, company$sex, summary) `

See `?summary`

` # Compare salary - you need to decide if these tests are appropriate t.test(salary ~ sex, company) wilcox.test(salary ~ sex, company) `

See `?t.test`

, `?wilcox.test`

, http://www.statmethods.net/stats/ttest.html and http://www.statmethods.net/stats/nonparametric.html