Is there a way to assign two different colours according to categorical values in rect graph??
rect(0, yb, Studies.sort,yt,col=("black","lightgray"[Area$"Theory"])
obviously.. this is wrong…..
Area consist of two categorical variables – “Theory” and “Vocational”.
You were close, the following works:
It is important that group here be a factor (not just a character vector). However if you use a named vector of the colors (with the names matching the group variable) then it would also work with a character vector.