我有调查数据,其中涉及参与者的回答。
我的数据格式为4 3 2 3 3 3 3 3 3 3 3 4 3 3 3 3 3 3 2 3 3
或者,以dput
格式:
c(4,3,2,4,3)
但是我想将它们归类为
strongly disagree = 1
disagree = 2
agree = 3
strongly agree = 4
,以便在进行直方图绘制时可以使用不同的颜色。
我尝试使用此方法
datatat = survey$Q1A
catsurvey <- cut(datatat,breaks =c(0,4),labels=c("Disagree","Agree","Strongly Agree"))
hist(datatat,main="Distribution of Player Ratings",xlab="Responses",border = "black",col = c("blue","red","green"))