我有一个员工数据的文本文件,其中包括员工收到的加薪、员工是否协商加薪以及员工的性别。我要做的是根据员工的性别以及他们是否协商加薪,创建一个员工收到的加薪金额的直方图。当我运行我的代码时,我不断收到此错误:无效的“中断”数。有人可以告诉我哪里出错了。
这是文本文件的示例:
emp received negotiated gender year
25 12.5 TRUE F 2013
318 5.2 FALSE F 2013
417 9.8 FALSE M 2009
523 6.8 TRUE M 2009
1218 2.1 TRUE F 2009
2601 13.9 FALSE M 2006
2225 7.8 TRUE M 2006
3000 8.5 FALSE F 2006
这是我正在尝试做的一些最小代码:
d<-read.csv("employees.txt", header=TRUE, sep="\t")
cat("\nDisplay what was loaded:")
str(d)
abline(m)
abline(mean(d$received), 0, lty=2)
hist(d$received[d$negotiated == TRUE && d$gender == '1'], main = 'Male Employees Who Negotiated Raises' )
dev.new()
hist(d$received[d$negotiated == TRUE && d$gender == '2'], main = 'Female Employees Who Negotiated Raises' )