0

I've got excel file with my data, I used "readxl" package to transport data to R. I've got several variables, one of these is called "EMPLOYEE ATTITUDE", it contais three types of grades - A, B and C. I wanted to use summary function to check what is the average hourly rate among employees who gained "A" grade.

Data=read_excel("Data.xls")
attach(Data)
 summary(subset(Data, EMPLOYEE ATTITUDE == A)$"HOURLY RATE")

and it's not working. I've tried to make variable "EMPLOYEE ATTITUDE" to be seen as a factor by commend

Attitude=factor(EMPLOYEE ATTITUDE)

but i still see the communicat that there is no such object as "A"!

hyiltiz
  • 1,158
  • 14
  • 25
wrzosowa
  • 9
  • 3
  • 3
    Try replacing `"HOURLY RATE"` with `\`HOURLY RATE\`` and `EMPLOYEE ATTITUDE` with `\`EMPLOYEE ATTITUDE\``. – Martin Gal Jun 03 '20 at 17:14
  • 1
    Please take a look at [How to make a great reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). You question doesn't contain any data nor the exact error message you are facing. – Martin Gal Jun 03 '20 at 17:17
  • Although I think that @MartinGal is on the right track, I think that usually if your column name has a blank in it, xlsx will replace it with a period. So try `Hourly.Rate` – G5W Jun 03 '20 at 17:19
  • Error in command 'eval(e, x, parent.frame())':object 'A' can't be found when i tried with summary(subset(Data, 'EMPLOYEE ATTITUDE' == A)$'HOURLY RATE') – wrzosowa Jun 03 '20 at 17:28

1 Answers1

0

you could run:

summary(subset(Data, `EMPLOYEE ATTITUDE` == "A","HOURLY RATE"))
Onyambu
  • 67,392
  • 3
  • 24
  • 53