Stack Exchange
Assigning different colors to variables in a barplot in R programming
I have this 
test scores <- c(96, 71, 78, 95, 82, 61, 62, 68)

And I want to represent test scores above 80 in a barplot with red color and below 80 with blue color.
What I have tried:
testscores <- ifelse(testscores >=80, "blue", " red")

I an and error message

Error: unexpected input in "testscores <- ifelse(testscores >=80, ""


testscores <- c(96, 71, 78, 95, 82, 61, 62, 68)
cols <- ifelse(testscores >=80, "red", " blue")
barplot(testscores, col = cols )

This should work as intended?


Thank you heck1.. What if I want to attach the scores under each bars?

testscores <- c(96, 71, 78, 95, 82, 61, 62, 68)
ifelse(testscores >=80, "blue", " red")

No problem.
